Page 1
NEWPROG2 & NPPTOC
Contents
What is A-NEWPROG? And NPPTOC? ............................................... ............................................ 1
B-Use of NEWPROG ............................................. .................................................. ................. 3
1) Structure of a NEWPROG program .......................................... ............................................ 3
2) NEWPROG compilation in bytecode and execution .......................................... .......................... 4
3) Translation in C with NPPTOC, compilation in machine code and execution ............................. 5
C-Variables, data spaces, typing in Newprog and the case of uninstantiated lists ...................... 6
1) Variables ............................................... .................................................. ..................................... 6
2) Data spaces ............................................. .................................................. ...................... 6
3) Typing of variables ............................................. .................................................. ..................... 9
4) Uninstantiated lists ............................................. .................................................. ................. 12
D-List of functions ............................................. .................................................. ........................... 13
1-Memory functions .............................................. .................................................. ..................... 13
2-Jump functions .............................................. .................................................. ........................... 25
3-Text display functions ............................................ .................................................. ....... 32
4-Text manipulation functions ............................................ .................................................. .36
5-Graphic functions .............................................. .................................................. .................. 40
6-Keyboard functions .............................................. .................................................. ....................... 54
7-Tibasic functions .............................................. .................................................. ........................ 59
8-Interrupts / timers functions ............................................ .................................................. ..... 64
9-Binary operations functions ............................................. .................................................. ..... 67
10-Arithmetic and logical operations functions ........................................... ........................... 68
11-Various functions .............................................. .................................................. .................... 70
12-Library functions .............................................. .................................................. ................... 71
E-Bookstores .............................................. .................................................. ................................... 72
1) Introduction ............................................... .................................................. .............................. 72
2) General: Loading - Function calls - Closing in a Newprog program. 72
3) Creation of personalized libraries from a Newprog code ..................................... ....... 73
4) Creation of personalized libraries from pure C code .................................... .............. 74
F-Compilation warning / error reports ..................................... ................................ 77
G-Predefined constants .............................................. .................................................. .................... 78
H-Acknowledgments ............................................... .................................................. .............................. 79
Appendix 1 - Internal structures of current files on TI68k ........................................ ................ 80
Annex 2 - Version history ............................................. .................................................. .... 84
What is A-NEWPROG? And NPPTOC?
Newprog is an on-calc programming language which greatly extends the possibilities of Ti
basic and offers high execution speeds (30 to 3000 times faster than the Tibasic). The
Newprog instructions functions allow:
• Editing programs directly in the classic Tibasic program editor

Page 2
NEWPROG2 & NPPTOC
• A syntax close to Tibasic
• Low-level access and manipulation of TIOS memory and file system
• The use of graphic functions derived from the assembler
• High level and low level access to keyboards
• The use of timers and interrupts
• To interlace Tibasic code with Newprog code
• The creation and use of libraries (thus extending capacities to those of C)
The source files can be compiled in two formats:
1. In bytecode (as in python or java): requires the use of a machine
virtual to be executed
2. Since Newprog2 and the associated appearance of NPPTOC : In machine language
(ASM - 89z files): directly executable
>> A prior compilation in bytecode is necessary
Note: See the corresponding sections for more details
What's new with the release of Newprog 2:
1. Rewrite the documentation. It becomes more explicit and streamlined.
2. Bug fixes.
3. Minor modifications to the syntax of certain functions.
But above all:
4. Possibility of creating and using its own ASM libraries (source codes in Newprog or in
VS). Thus, extend the possibilities to all the instructions of C.
5. Possibility of converting a Newprog bytecode file into machine code, further increasing
significantly the speed of execution of the program. This will require going through a
intermediate step which consists in translating a file in Newprog bytecode in C language
directly (and only) on the calculator with NPPTOC then to compile it with a
compiler C.
The possible compilers are:
• GTC version installed directly on the calculator (oncalc)
• GCC4TI for PC
◦ Each compiler has its advantages and disadvantages:
GTC oncalc version:
Advantage:
◦ 100% compilation on calculator: No need for transfers from TI to PC and PC

Page 3
NEWPROG2 & NPPTOC
to TI.
Disadvantages:
◦ Executable files less optimized and therefore slower and larger
◦ Compilation very greedy in RAM memory. Therefore, only programs of
moderate sizes will fit under their compilations.
◦ Joint use of an external library ('npplib2.89z') for certain functions
(mainly graphics) → loading takes time and requires a bit of
RAM memory
GCC4TI for compilation on a computer:
Advantages :
◦ Executable files (machine code) optimized in size and speed.
◦ Can compile large source files
◦ No need for the external library 'npplib2.89z' therefore faster execution at launch
and requires less RAM memory
Disadvantages:
◦ Need to transfer C source files from TI to PC
◦ Then ask for some manipulations in Windows file explorer:
▪ Convert .89t source files to .C files and optionally to .h files
▪ Transform the first line of 'cout.C' into a comment (addition of '//')
▪ Move these files to the appropriate directories of GCC4TI
◦ Then create a C project in the GCC4TI IDE and insert the converted files into it in
the step just above (this is done, the compilation can be started).
◦ Then transfer the executable from the PC to the IT
B-Use of NEWPROG
1) Structure of a NEWPROG program
The source code of a Newprog program has the particularity of being written directly in the editor of
program of classic Tibasic programs: APPS + Program Editor
The Newprog syntax is therefore close to the structure of a Tibasic program.
The 'init ()' instruction must be placed on the first line. It characterizes a Newprog program.
A particularity of the Newprog language is that it allows to interleave sequences of codes

Page 4
NEWPROG2 & NPPTOC
Newprog with classic Tibasic sequences. During execution (see corresponding section), the
virtual machine, or interpreter, will distinguish it and interpret the instructions in the
adequate language. This is very useful because it makes it possible to offer the vast majority of the possibilities of the
Tibasic, in addition to the possibilities of the Newprog instructions. To specify a Tibasic sequence, it
just put its instructions between the 'basic' and 'endbasic' tags.
Example of Newprog program structure:
: init ()
//mandatory. Corresponds to the initialization of the interpreter (or virtual machine).
: newprog_instruction1
// first Newprog instruction
: newprog_instruction2
// second Newprog instruction
: basic
// tag specifying the start of a Tibasic sequence
: tibasic_instruction1
// first Tibasic instruction
: tibasic_instruction2
// second Tibasic instruction
: endbasic
// tag specifying the end of a Tibasic sequence
: newprog_instruction3
// third Newprog instruction
2) NEWPROG compilation in bytecode and execution
To compile and run a Newprog source program, the recommended method is to run
in the HOME screen the following command:
npcc ("myprgm") where 'myprgm' is the name of your source program.
For information, the 'npcc.89p' program internally performs the following steps:
1. Syntax check (as in any launch of a Tibasic program). Amounts to
run 'myprgm ()' and type 'esc' when an error message appears.
2. Archiving of the source program in view of a possible crash of the calculator
3. Copy the source program to the 'zbackup' directory
4. Unarchiving the 'out.NPP' file in order to be overwritten in the next step
5. Conversion to Newprog bytecode : creation of the 'out.NPP' file. This step proceeds to a
pre-check of the program structure. If an error appears, the conversion will be
addressed. This is the same as running 'newprogc ("myprgm")'.
6. Display of possible warnings : Points the user to possible errors
(mainly secondary forgetfulness)
7. Display of a message inviting to test the program .
8. Running the program in the virtual machine (equivalent to running 'newprog ("out")')
9. Once the program is finished, asks to unarchive the program.
source (select no if the calculator seems unstable)
The user can rename the generated 'out.NPP' file to whatever name they want. To run this
program (.NPP) in the virtual machine (also called interpreter), as seen above, it
must run 'newprog ("mynpp.NPP")' where 'mynpp' is the new name given.

Page 5
NEWPROG2 & NPPTOC
3) C translation with NPPTOC, machine code compilation and execution
Translation into C language of the Newprog file 'out.NPP':
When executing the 'npptoc ()' command in the HOME screen, the 'out.NPP' file will be converted into
C language. The output file 'cout.TEXT' (main C file) and possibly other files
(.TEXT) will be generated (headers files).
In order to avoid the display of an error indicating a lack of memory during the translation,
Please free up as much RAM as possible, either by archiving or deleting files. Yes
this is not enough, it will be necessary to reset your calculator and restart the process.
The translation is finished.
Compile to .ASM file with GTC oncalc and run:
You must have previously installed GTC on your calculator.
To compile the previously generated C source files, follow these steps:
1. Unarchive the 'outbin.ASM' file if there is
2. Start 'gtc_ide ()'
3. Select the 'main \ cout' file
4. Press F5 to start compilation
5. The output executable file is 'outbin.ASM'. It can be tested.
If the compilation displayed a memory error, archived all your files and restart the
compilation. If the memory error is still present, reset your calculator. If the error is
still there, you will have to compile on PC.
Note: running 'make ("ouput_name")' will automate these steps and rename the file from
output to "output_name".
Compile to .ASM file with GCC4TI on PC and run:
1. Transfer the previously generated C files (* .TEXT ') to your PC.
2. Rename the file 'cout.89t' to 'cout.c' and the other headers files to '* .h' (example
'execbash.h')
3. Open these files one by one with a text editor (Notepad for example) and delete the
unnecessary characters at the start of the file and at the end of the file
4. In the 'cout.c' file, comment out the first line by adding '//' at the start of
line: // #define GTC_ONCALC // undo this line if with GCC4TI
5. Move / insert these files to your GCC4TI directories
6. Start the compilation (have created a GCC4TI project beforehand)
7. The 89z file is generated and can be tested.

Page 6
NEWPROG2 & NPPTOC
C-Variables, data spaces, typing in
Newprog and the case of uninstantiated lists
1) Variables
The variables in Newprog are written in a similar way to the classical variables in Tibasic and C.
They are written with a minimum of two characters and a maximum of eight characters. Example:
• value or var1 or vv or xx or index
They all have a size coded on 4 bytes, their values ​​can be between:
• -2 147 483 648 to + 2 147 483 647
Variables, depending on their type (number or pointers, see paragraph A-3), can also be used
to handle data spaces (see paragraph A-2)).
2) Data spaces
As in Tibasic or in C, a data space is a memory space composed of data of
same type, stored contiguously in memory (one after the other). The pointer of
this memory space is the address of the first data. This value is contained in a variable.
We can handle the data space thanks to this variable.
A data space is therefore a series of cells (memory space) of the same size. The size of
each of the boxes is conditioned by the type of data that the data space contains (see
lower).
The elements of the array can be:
• If the type of the variable is 1: each data item is coded on 1 byte
• If the type of the variable is 2: each data item is coded on 2 bytes
• If the type of the variable is 4: each data item is coded on 4 bytes
• If the type of the variable is other: each data item is a sequence of X bytes, where X is
the number of bytes
Example:
Addresses
A + type * 0
A + type * 1
A + type * X
A + type * (N-1)
Item #
1
2
X + 1
NOT
This memory space contains N data of type 'type' and is pointed to by A.

Page 7
NEWPROG2 & NPPTOC
They can be fixed or dynamically allocated, but their structures follow the same principles,
only their means of construction are different. In the case of dynamic allocation, it
make sure to delete them from the RAM memory before the end of the execution of the program under
it is worth losing the amount of available memory (if you forget, you will have to reset the RAM memory
to retrieve it).
For example, you can store a string of characters to store text, information
like numbers of different lengths (a person's age, etc.). They are common to the
overwhelming majority of programming languages. These data spaces store the
properties of those of the C language.
To manually read the elements of a data space, see the '[]' function (as in Tibasic
or C) (or incidentally 'lw-lb ()' 'peekb-wl ()' etc ...).
To manually modify the elements of a data space, see the '→' function (as in
Tibasic or C) or 'sto ()' (or 'wb-wl ()' 'pokeb-wl ()' etc ...).
List type:
A list is a data space used to store numbers of all types.
Static definition of lists:
We define each element of the list with the notation 'bwl: ...: y'. We cannot statically define
a list with types 1, 2 or 4:
• by for a type 1 list
• wy for a type 2 list
• ly for a type 4 list
Example:
b (list_name)
element1 value
element2 value
….
element valueN
y
The C equivalent is:
char list_name [] = {value element1, value element2, ..., value elementN};
In order to relieve the programmer, when a series of 'number of occurrences' elements of the same
value 'value' is desired, you can use the keyword 'repeat (number_of occurrences, value)'.
Example:
w (list_name)

Page 8
NEWPROG2 & NPPTOC
element1 value
repeat (5.0)
element value7
y
The C equivalent is:
int list_name [] = {value item1,0,0,0,0,0, value item7};
This notation is very useful for defining sprites.
For example, to define a sprite that represents an 8x8 side square as follows (value
defined in binary):
b (name_sprite)
0b11111111
0b10000001
0b10000001
0b10000001
0b10000001
0b10000001
0b10000001
0b11111111
y
Here, we could replace the six lines '0b10000001' by 'repeat (6,0b10000001)'.
Dynamic definition of lists:
a) It is possible to dynamically create lists using the notation:
'{list_name, elems_size, elem1, elem2, ..., elemN}'
At runtime, a memory space of elems_size * N bytes will be created and each of its elements (all
of size 'elems_size' (only 1,2,4 allowed) will be assigned to the value 'elemX'.
Make sure to free the memory space before the end of the execution of the program with the 'free ()' function.
For further information, see the corresponding section.
Example:
The Newprog code '{list, 4,12,23}' returns to the following C code:
char * list;
if (! list = malloc (4 * 2)) return;
list [0] = 12;
list [1] = 23:
This C code can also be written with its Newprog analogue.

Page 9
NEWPROG2 & NPPTOC
b) You can also use the 'group ()' function to define a list dynamically. See
corresponding section.
Type of character string or string:
A character string (or string) is a data space encoded on 1 byte (type 1) and which is used
to manipulate sentences (for example with a view to displaying them in the program).
They are defined as follows:
"This is a character string": You must place its content between each '' '' (Same as in
Tibasic). To be able to handle it, we record its pointer, i.e. the address of the first
character, in a variable for example using the '→' or 'sto ()' function.
In a more complex way, we can also define it as any list, where it will be necessary
assigned each element with the ASCII code of the corresponding letter. The last element should
be equal to 0 to be able to handle this character string with the functions that go well
('printf-1-2 ()', 'strlen ()', 'strcat ()', etc ...).
Newprog code example:
: init ()
: '' Hello '' → str // save the pointer to the data space of the string in the
variable named str. Its type is 1 (see A-3)).
: text str
// We then display Hello on the screen for example
If we represent its structure in memory, it will be as follows:
Addresses
A + 0 A + 1
A + 2
A + 3
A + 4
A + 5
A + 6
A + 7
ASCII codes 66
111
110
106
111
117
114
0 (obligatory)
Characters
B
o
not
j
o
u
r
\ 0
The value of str will be equal to A + 0 i.e. A. Each character corresponds to an ASCII code (same as in
Tibasic and C).
To read any value at its corresponding position in this space, it is convenient
to use the '[]' notation (other functions like 'lb ()' or 'peekb ()' exist). I'm not going to
expand because it's like in Tibasic and C.
Note: Tibasic variables are also a kind of data space. The content of this space
set the variable itself. Data space may be required to create variables
Tibasic of all types. See function 'fopen ()' and 'fcreate ()'.
3) Typing of variables
Each variable is associated with a type. Typing by a value is specific to Newprog. The value
of type can range from 1 to 65535. These type values, except for type 5, correspond to
pointers to data. Type 5 is the default type, corresponding to signed integers type 'long'
in C.
The type can be defined manually with the 'settype ()' function or automatically when

Page 10
NEWPROG2 & NPPTOC
the use of certain functions (see below).
The different possible types:
• Type 1 corresponds to a pointer to data encoded on 1 byte. The C equivalent is
'tank *',
• Type 2 corresponds to a pointer to data encoded on 2 bytes. The C equivalent is
'int *'. As in C, this pointer must be even,
• Type 4 corresponds to a pointer to data encoded on 4 bytes. The C equivalent is
'long *'. As in C, this pointer must be even,
• Type 5 corresponds to a signed integer variable of standard value, like any other
number. It is dedicated to classical arithmetic calculations + - * /. The C equivalent is 'long',
• The other types (except 5), are pointers to data of personalized lengths,
specific to Newprog and having no equivalent in C. Their C equivalent remains all the same
of 'char *'. They were designed to simplify certain tasks. They can be useful with
the 'files ()' and 'reps ()' functions but for other programmer's needs (see function
'sto ()').
A variable can only have one and only one type in the whole body of the program (since Newprog
2 to ensure a good conversion into C language with NPPTOC).
Variables and their respective types are declared when they first appear in the body of the
program. You cannot assign more than one type to a variable (an error message will appear).
Automatic assignment of types:
1. First appearance as a destination variable (named dest) in the functions and
following instructions will directly affect dest to type 1 :,
◦ newstr (X, dest)
◦ seqb (dest, X, X, X, X, X)
◦ "X" → dest
◦ string (X) → dest
◦ char (X) → dest
◦ fopen (X) → dest
2. First appearance as destination variable (named dest) in functions and
The following instructions will directly affect dest to type 2:
◦ seqw (dest, X, X, X, X, X)
3. First appearance as a destination variable (named dest) in the functions and
The following instructions will directly affect dest to type 4:
◦ seql (dest, X, X, X, X, X)
◦ group (nilist) → dest

Page 11
NEWPROG2 & NPPTOC
4. First appearance as destination variable (named dest) in functions and
The following instructions will directly affect dest to type 10:
◦ reps (dest)
◦ files (X, dest)
Examples and use cases; Newprog codes relating to the typing of variables:
Example 1:
: init ()
: 3 → num
// num is of the default type, i.e. 5
: settype (num, 5)
// Useless, but no error because the type is already 5
: num * 2 → num2
// num2 is type 5 by default
Example 2:
: init ()
: seqb (listb, va, 1,4,1, va)
// The type of listb is set to 1
: listb [3] + 1 → vb
// vb is type 5
: listb + 1 → vc
// vc is of type 5. In C, the type of vc would be of type 'char *'. The
logic would make it the same in Newprog. Newprog does not, so you have to set the type
of vc before this line. We will then write:
: init ()
: seqb (listb, va, 1,4,1, va)
// The type of listb is set to 1
: listb [3] + 1 → vb
// vb is type 5
: settype (vc, 1)
// we set the type of vc before its first use
: listb + 1 → vc
// vc is always type 1
Example 3:
: init ()
: 3 → num
// num is of the default type, i.e. 5
: settype (num, 4)
// forbidden because the type is already 5
Example 4:
: init ()
: 3 → num
// num is of the default type, i.e. 5

Page 12
NEWPROG2 & NPPTOC
: seqb (num, X, X, X, X)
// forbidden because the type of num is already 5
Example 5:
: init ()
: char (100) → str
// The type of str is 1
Off topic, but for information,: str [0] would give 100.
4) Uninstantiated lists
The Newprog language offers a unique possibility which is a hybrid between the Tibasic and the C language,
these are the uninstantiated lists (nilist).
They are written as follows: {instruction1 [, instruction2…]} where the instructions
between '[]' are optional. This writing can be confusing with dynamic instantiated lists
(see corresponding section) in the case where instruction1 is a single variable. So that the
compiler does not confuse it with a dynamic instantiated list, a trick is to trick it into
rewriting the original instruction1 named for the example 'instuc1' as follows: 'instuc1' + 0
They are useful on a case-by-case basis depending on the Newprog functions that use them (for that, see
their corresponding sections). These functions are:
• 'toos ()'
• 'when ()'
• 'inter ()'
• 'group ()'
• 'libfuncs ()'
• 'testfc ()'

Page 13
NEWPROG2 & NPPTOC
D-List of functions
1-Memory functions
Function: valuedestination or sto (destination, value)
Assigns the value value to destination. Different writings are possible:
1) Destination can be a variable.Value and var can be of any type. Assigns the value value
to the variable named 'var':
: value → var
Equivalent C code:
var = value;
For the cases below, it is advisable to refer to the settype () function to understand the
notion of variable type.
2) Destination can be an element of a list of type 1 or 2 or 4 (or even 5, returns to a type 4).
Assigns the value value to the index element index of the list 'list':
: value → list [i]
The equivalent C code would be:
If type is 1:
long sto_in_list (char * list, unsinged int index, char value)
{
list [index] = value;
}
void _main (void)
{
char list [size];
sto_in_list (list, index, value);
}
If type is 2, replace 'char list [size]; 'by' int list [size]; '
If type is 4 (or even 5), replace 'char list [size];' with 'long list [size];'
3) Destination can be a list of another type (other than 1 2 4/5). In this case, value will be
considered as a type 1 pointer and its contents at type bytes height will be copied to the
pointer corresponding to list [elem] (in C, corresponds to 'list + elem * type').

Page 14
NEWPROG2 & NPPTOC
: init ()
: b (buff1)
// buff1 is a memory space composed of 20 times 0. It is of type 1
: repeat (20,0)
: y
: settype (buff2,15)
// as in Newprog2, we cannot modify the type of a pointer,
then we create buff2 with a type equal to an arbitrary size of 15 (less than 20)
: buff1 → buff2
// buff2 points to the same memory space as buff1
: "Hello World!" → buff2 [0] // copy "Hello World!" To the address buff2 [0] or buff + 0 x 15
: prints (buff2 [0])
// displays: "Hello World!"
: keywait ()
The equivalent C code would be:
void _main (void)
{
char buff1 [20], * buff2;
memset (buff1,0,20);
buff2 = buff1;
memmove (buff2 + 0 * 15, "Hello World!", 15);
printf ("% s", buff2 + 0 * 15);
ngetchx ();
}
4) Destination is the function 'osvar (os_var)' as in: value → osvar (os_var). Here the value
value will be saved in the tibasic variable named os_var. Make sure that os_var is not
archived or not a system variable. Further information is
given in the Tibasic Functions section.
• Classic value: Store the value 666 in the variable tibasic xx
: 666 → osvar (xx)
• Value being a direct string (without #): Affects the variable tibasic xx with the string tibasic
" Bonjour Monde ! "
: "Hello World!" → osvar (xx)
• Value being a pointer to string using #: Assigns the variable tibasic xx with the string
tibasic "Hello World!"
: "Hello World!" → str
// str is the pointer to string
: # str → osvar (xx)
Not working with NPPTOC:
• #value with value being a reference on an uninstantiated list:. Assign a tibasic variable
with the content of the reference of an uninstantiated list (being value). Example, save
the list tibasic {1, "hello", 3} in the variable tibasic xx
: {1, "hello", 3} → nil
: # nil → osvar (xx)

Page 15
NEWPROG2 & NPPTOC
Function: settype (data_size, var)
This function is attached to the notion of type (see the corresponding section). Of a certain
way, it can facilitate programming. To be used with the notation [].
Selects the type of data pointed to by the newprog var variable (by defining their size
data_size expressed in bytes). The data_size input data can take the following values:
• 1: var points to a data table coded on 1 byte (= 1byte). (Reading: var [ii];
write: data_to_store → var [ii])
• 2: var points to an array of data coded over 2 bytes. (Read: var [ii]; write:
data_to_store → var [ii])
• 4: var points to an array of data coded over 4 bytes. (Read: var [ii]; write:
data_to_store → var [ii])
• other values: var points to an array of character strings (or string). Each
string must have a maximum size of data_size-1 (not counting the zero of
end of character string). Or in other words, the memory space of each element is
data_size bytes. To use the return lists of the reps () and files () functions, data_size
must be equal to 10. (Read: var [ii]; write: pointer_data_to_copy → var [ii] (for
information, internally performs a memmove ())).
The functions seqb (), seqw (), seql () automatically assign the size of the elements to the variable of
output during their executions.
Example for data size having a value of 'lcdsize' (different from 1,2,4):
: init ()
: settype (ptr, lcdsize)
: settype (lcd, lcdsize)
: malloc (lcdsize * 2) → ptr
// creates buffer
: if ptr = 0 then
: text "mem error"
: finish ()
: endif
: getlcd () → lcd
: lcd → ptr [0]
// copy the screen area in ptr [0] area
: text "Screen saved"
: memset (ptr [1], - 1, lcdsize) // fill ptr [1] area (ie ptr [0] + lcdsize) with 0b11111111
: ptr [1] → lcd [0]
// copy ptr [1] area to screen area
: text "Screen filled"
: ptr [0] → lcd [0]
// copy ptr [0] area to screen area

Page 16
NEWPROG2 & NPPTOC
: text "Screen restored"
: free (ptr)
Function: malloc ( size_in_bytes )
Dynamically allocates a memory space of size_in_bytes bytes on demand. The
function returns the pointer of the allocated memory space. We must manually free up the space
memory with the 'free ()' function before the end of the program to avoid memory loss,
for this it is essential to store the return pointer of this function (commonly in
a variable). If you want to use the '[]' notation to read or write to this memory space
(via a variable), the type of the memory space will be converted to that of the type of the variable
destination in the case of a 'malloc (x) → var' notation ('settype ()' function).
Equivalent in C: malloc () function
Code of the Newprog 'newstr2 ()' function similar to the 'newstr ()' function:
: def (newstr2 (str))
: malloc (strlen (str) +1) → buff
: if not buff: rtn (0)
: strcpy (buff, str)
: rtn (buff)
: enddef (newstr2 ())
Function: realloc (ptr, new_size)
'realloc ()' is used to modify the size of the previously allocated memory block pointed to by ptr (with
malloc (), seqb (), etc ..) to size new_size. Realloc () returns a pointer to the new block
memory (the block that may have changed location in the memory). The contents of the memory block
is not lost during resizing. Returns 0 and frees the memory block pointed to by ptr if
the memory block could not be reallocated. Like 'malloc ()', you will have to manually free up the space
memory with the 'free ()' function.
Equivalent in C: realloc () function
Function: free (ptr)
Releases the memory space pointed to by ptr which was previously allocated with functions such as
like 'malloc ()' or 'seqb ()', 'seqw ()', 'seql ()', 'group ()' for example. If ptr does not point to a space
existing memory allocated dynamically, the function will crash the calculator.
Equivalent in C: free () function

Page 17
NEWPROG2 & NPPTOC
Function: memset (ptr, value, nb_bytes)
Assigns nb_bytes bytes with the value value starting from the address ptr. This function is fast.
Equivalent in C: memset () function
Code of the Newprog function 'memset2 ()' equivalent of the function 'memset ()':
: def (memset2 (ptr, value, nb))
: settype (ptr, 1)
: for i, 0, nb-1,1
: value → ptr [i]
: endfor
: trn (ptr)
: enddef (memset2 ())
Equivalent in C:
long memset2 (char * ptr, char value, unsigned int nb)
{
unisgned int i;
for (i = 0; i <nb; i ++) ptr [i] = value;
return ptr;
}
Function: memcpy (dest, src, len)
Copies a memory block of size l in bytes from the memory space pointed to by src to the memory space
pointed to by dest. If src overlaps dest, memcpy () may crash the calculator (in this case use the
memmove () function).
C equivalent: memcpy () function
Example:
: init ()
: malloc (lcdsize) → ptr // Allow space for lcd saving
: if not ptr: finish ()
: memcpy (ptr, getlcd (), lcdsize) // Save the screen in ptr
: text "screen saved"
: memset (getlcd (), 255, lcdsize) // Fill the screen with black
: text “The screen is filled”
: memset (getlcd (), ptr, lcdsize)
: text "screen restored"
: free (ptr)

Page 18
NEWPROG2 & NPPTOC
Function: memmove (ptr_dest, ptr_src, len)
Quite similar to the 'memcpy ()' function. Copy a memory space in bytes from ptr_src to
ptr_dest. In addition to the 'memcpy ()' function, 'memmove ()' allows you to have memory spaces
pointed to by overlapping ptr_src and ptr_dest. This function returns ptr_dest.
C equivalent: memmove () function
Function: memchr (ptr, value, len)
Syntax: memchr (str, c, len) Description:
Find in the first len ​​bytes of the memory block pointed to by ptr, the pointer of the first
occurrence of value. Return this pointer. If 'memchr ()' did not find the character c, then returns 0.
C equivalent: memchr () function
Example: Poster "345"
: init ()
: "12345" → ptr
: text memchr (ptr, ord ("3"), strlen (ptr))
Function: seql (var_dest, var, start, end, step, instruction)
Warning: This function has been modified since version 2.0.
Dynamically allocates a memory space of (end-start + 1) * 4 bytes and assigns in order each
elements coded on four bytes of this memory space by the value of the execution of
the instruction instruction and that for a value of the variable var going from start to end with a
no step. This function returns the pointer to the allocated memory space and also stores its value
in the variable var_dest Returns 0 if not enough memory. Care should be taken to remove this
memory space before the end of program execution (with 'free ()').
If the type of the destination variable has not yet been defined, then it will automatically be
assigned to type 4. If the type was already defined and different from 4, an error message will appear at
execution or translation in C with NPPTOC.
The following Newprog code:
: seql (listl, xx, 0,5,1,2 * xx)
will give the contents of the memory space pointed to by long * listl [] = {0,2,4,6,8,10};
Equivalent C code:
long * listl, xx, i;
listl = malloc (4 * (5-0 + 1));
if (listl)
{

Page 19
NEWPROG2 & NPPTOC
i = 0;
for (xx = 0; xx! = (5 + 1); xx + = 1)
{
listl [i] = 2 * xx;
i ++;
}
}
Example of Newprog code execution:
: init ()
: seql (list, va, 1,4,1, va)
: if not list: finish ()
// equivalent to: if list = 0: finish ()
: for vb, 0,3,1
: printld (list [vb])
: EndFor
: free (list)
: keywait ()
Will display: "1234"
Function: seqw (var_dest, var, start, end, step, instruction)
Warning: This function has been modified since version 2.0.
Dynamically allocates a memory space of (end-start + 1) * 2 bytes and assigns in order each
elements coded on two bytes of this memory space by the value of the execution of
the instruction instruction and that for a value of the variable var going from start to end with a
no step. This function returns the pointer to the allocated memory space and also stores its value
in the variable var_dest. This function returns 0 if the memory space runs out. It will take
make sure to delete this memory space before the end of the execution of the program (with 'free ()').
If the type of the destination variable has not yet been defined, then it will automatically be
assigned to type 2. If the type was already defined and different from 2, an error message will appear at
execution or translation in C with NPPTOC.
The following Newprog code:
: seqw (listw, xx, 0,5,1,2 * xx)
will give the content of the memory space pointed to by int * listw [] = {0,2,4,6,8,10};
Equivalent C code:
int * listw;
long xx, i;
listw = malloc (2 * (5-0 + 1));

Page 20
NEWPROG2 & NPPTOC
if (listw)
{
i = 0;
for (xx = 0; xx! = (5 + 1); xx + = 1)
{
listw [i] = 2 * xx;
i ++;
}
}
Example of Newprog code execution:
: init ()
: seqw (list, va, 1,4,1, va)
: if not list: finish ()
// equivalent to: if list = 0: finish ()
: for vb, 0,3,1
: printld (list [vb])
: EndFor
: free (list)
: keywait ()
Will display: "1234"
Function: seqb (var_dest, var, start, end, step, instruction)
Warning: This function has been modified since version 2.0.
Dynamically allocates a memory space of (end-start + 1) * 1 bytes and assigns in order each
elements coded on a byte of this memory space by the value of the execution of the instruction
instruction and this for a value of the variable var going from start to end with a step step.
This function returns the pointer to the allocated memory space and also stores its value in the
variable var_dest. This function returns 0 if the memory space runs out. It will be necessary to ensure
delete this memory space before the end of the execution of the program (with 'free ()').
If the type of the destination variable has not yet been defined, then it will automatically be
assigned to type 1. If the type was already defined and different from 1, an error message will appear at
execution or translation in C with NPPTOC.
The following Newprog code:
: seqb (listb, xx, 0,5,1,2 * xx)
will give the content of the memory space pointed to by listb: char * listb [] = {0,2,4,6,8,10};
Equivalent C code:
char * listb;

Page 21
NEWPROG2 & NPPTOC
long xx, i;
listb = malloc (2 * (5-0 + 1));
if (listb)
{
i = 0;
for (xx = 0; xx! = (5 + 1); xx + = 1)
{
listb [i] = 2 * xx;
i ++;
}
}
Example of Newprog code execution:
: init ()
: seqb (list, va, 1,4,1, va)
: if not list: finish ()
// equivalent to: if list = 0: finish ()
: for vb, 0,3,1
: printld (list [vb])
: EndFor
: free (list)
: keywait ()
Will display: "1234"
Function: group (nilist)
This function transforms the uninstantiated list nilist into an instantiated list with its encoded elements
on 4 bytes (bytes). This function returns a pointer to the dynamically created memory block.
Returns 0 if the memory block could not be allocated. This memory block will first contain
position the number of elements converted then contains afterwards the instantiated elements of
nilist (can be elaborate instructions). The pointer value should be saved,
commonly in a variable (then manually assign the type to type 4 or 5, function
'settype ()'). The advantage of this function is that it is concise while relieving the programmer
to assign element by element by lines of successive assignments a memory space.
You must free the memory space by using the 'free ()' function before stopping the program.
This function returns 0 if the memory space runs out.
Newprog code example: Creation of a list of elaborate string pointers and display its
content item by item
: init ()
: settype (strlist, 4)

Page 22
NEWPROG2 & NPPTOC
: group ({"string" & string (1), "string2", "string" & "3"}) → strlist
: clrscr ()
: For vv, 1, strlist [0], 1
: prints (strlist [vv]): nl ()
: EndFor
: keywait ()
: free (strlist)
Result on screen:
string1
string2
string3
C code equivalent of the instruction: group ({1,1 + 1,3 * 1})
long * list;
list = malloc (4 * 4);
if (! list) return 0;
list [0] = 3;
list [1] = 1;
list [2] = 1 + 1;
list [3] = 3 * 1;
return list;
The Newprog code equivalent would be similar in structure. We can see the gain in writing lines.
Function: {dest_var, size_elem, elem1, elem2,…, elemn}
Dynamically defined instantiated lists. When this instruction is executed, a space
memory is created. The pointer of this memory space is then assigned automatically to the
variable dest_var (the instruction will also return the value of the pointer). This memory space is then
initialized as a list of n elements, each of size_elem bytes in size. The elements of
this list will be elem1, elem2 etc ... The elements must be of the type of a number (even constant
predefined) or a variable. Make sure to free the memory space created before the end of the program
to avoid memory loss ('free ()' function).
This instruction differs in two ways from the 'group ()' function:
-Items size can be customized (1,2,4,5)
-But cannot contain elaborate instructions (excluding direct numbers, variables and constants
predefined)

Page 23
NEWPROG2 & NPPTOC
Function: newstr (str, var_dest)
Allocate a memory space of the size of the character string str plus 1 (for the null character),
then copy all the characters from str to that memory space. The newprog var_dest variable is
then assigned to this pointer. This memory block must be freed with the 'free ()' function before the end of
the execution of the program under penalty of permanently losing the available RAM memory (a
reset is then necessary to recover it). The function returns the pointer of this memory space
allocated. This function returns 0 if the memory space runs out.
Newprog code example: Copy a string and compare it with the original
: init ()
: "Hello World!" → str1
: newstr (str1, str2)
: if not str2: finish ()
: if strcmp (str1, str2) = 0: text "str1 & str2 are the same"
: free (str2)
Function: lb (address, elem)
Returns the signed value of the element element of the 1-byte encoded memory space pointed to by address.
The first element has index 0.
The equivalent in C is: * ((char *) (address) + elem);
Example:
The following instruction group:
: settype (lcd, 1)
: getlcd () → lcd
: text "First screen byte =" & string (lcd [0])
Return to shorter writing:
: text "First screen byte =" & string (lb (getlcd (), 0))
Function: peekb (address)
Returns the signed 1-byte value of the address address.
Function: lw (address, elem)
Returns the signed value of the element element of the memory space coded on 2 bytes pointed to by
address.
The first element has index 0.
The equivalent in C is: * ((int *) (address) + elem);

Page 24
NEWPROG2 & NPPTOC
Example:
Take inspiration from that of 'lb ()'.
Function: peekw (address)
Returns the signed 2-byte value of the address address.
Function: ll (address, elem)
Returns the signed value of the element element of the 4-byte coded memory space pointed to by
address.
The first element has index 0.
The equivalent in C is: * ((long *) (address) + elem);
Example:
Take inspiration from that of 'lb ()'.
Function: peekl (address)
Returns the signed 4-byte value of the address address.
Function: wb (address, elem, value)
Assigns the value value to the elem element encoded on 1 byte of the memory space pointed to by address.
The first element has index 0.
The equivalent in C is: * ((char *) (address) + elem) = value;
Function: pokeb (address, value)
Assigns the 1-byte encoded element pointed to by address to value.
Function: ww (address, elem, value)
Assigns the value value to the 2-byte coded elem element of the memory space pointed to by address.
The first element has index 0.
The equivalent in C is: * ((int *) (address) + elem) = value;
Function: pokew (address, value)
Assigns the 2-byte encoded element pointed to by address to value.

Page 25
NEWPROG2 & NPPTOC
Function: wl (address, elem, value)
Assigns the value value to the element elem coded on 4 bytes of the memory space pointed to by address.
The first element has index 0.
The equivalent in C is: * ((long *) (address) + elem) = value;
Function: pokel (address, value)
Assigns the 4-byte encoded element pointed to by address to value.
2-Jump functions
Function: if condition then: ...: else: ...: endif
Same syntax and operation as the Tibasic function. If condition is true (ie different from
0), then the sequence of instructions after 'then' will be executed, otherwise it will be passed and it will be
the 2nd sequence after 'else' which will be executed. In this function, the 'else' block is not
mandatory. In this case, if condition is false, jump directly after 'endif'.
Equivalent in C:
if (condition)
{
…;
}
else
{
…;
}
Function: if condition: unic_instruction
Same syntax and operation as the Tibasic function. If condition is true (ie different from
0), then the single unic_instruction will be executed. If false, go to the instruction line
next.
Equivalent in C:
if (condition) unic_instruction;

Page 26
NEWPROG2 & NPPTOC
Function: finish ()
Exit the program to return to TIOS. The use of this instruction in a library is
prohibited.
Example: Allocate memory space. If not enough memory, displays the error "Not enough
memory "and quit the program
: init ()
: malloc (30000) → buff
: if not buff then
: text "Not enough memory"
: finish ()
: Endif
: text "Memory allocated"
: free (buff)
Function: while cond :: endwhile
As long as the cond condition is true (ie different from 0), repeat the instructions between '::'.
Same as Tibasic and C.
Function: for varname, begin, end, step :: endfor
Execute the instructions between the '::' by varying the variable varname from the value begin to the value
end value with a step step. Care must be taken that the end value is reached to avoid
an infinite loop.
Same as Tibasic.
The associated functions 'break ()' and 'next ()' provide additional functionality to
'For :: EndFor' loops. See corresponding sections.
Function: break ()
End a 'For: EndFor' or 'While: EndWhile' loop by skipping after it. In case
nesting such loops, the last active loop will be terminated. This allows you to leave a
loop manually.
Same as C.

Page 27
NEWPROG2 & NPPTOC
Example:
Will display in successive lines: vv = 1 vv = 2 vv = 3 vv = 4 vv = 5
: init ()
: clrscr ()
: for vv, 1,10,1
: prints (“vv =” & string (vv)): nl ()
: if vv = 5: break ()
: endfor
: keywait ()
Function: next ()
Jumps to the start of the last active 'For: EndFor' or 'While: EndWhile' loop. If it is a
'For: EndFor' loop, the variable will be assigned to its next value.
Similar to the 'continue' C function.
Function: def (fc_name ([arg1, arg2, ...])): Enddef (fc_name ())
Associated syntax: fc_name ([arg1, arg2, ...])
Associated function: rtn (value)
The 'def (): enddef' block defines a user function of name fc_name. If passing argument (s) to
function there is (arg1, arg2 ...), they will be considered as local variables. A local variable
can have the same name as a variable already defined in the program, but it will have its value
clean until the end of the execution of the function. User can change its value inside
of the function as an ordinary local variable (as in Tibasic and C). Its initial value
being equal to the argument passed to the function.
You must define the user function upstream in the code before calling this function. In good
practical, we list all these functions in the upper part of the program after the definition
possible types of Newprog variables ('settype ()' function, same philosophy as C).
Using the 'rtn (value)' function in the body of the 'def (): enddef ()' block allows you to exit the
function by returning the value value (similar to the 'return' statement of Tibasic and C).
To call the function, we will use the following conventional syntax:
• fc_name ([arg1, arg2, ...]): there must be the same number of arguments as the one defined in
upstream
Example: Poster "Hello World!" and then "And have a good day!"
: init ()
: "And have a good day!" → str
// Here the global variable 'str' is assigned
: def (hello (str))
// Start of definition of the user function 'hello ()'

Page 28
NEWPROG2 & NPPTOC
: str & "" → str
// Add a space to the local variable 'str' and reassign 'str'
: rtn (str)
// Return value of the function
: enddef (hello ())
// End of definition of user function 'hello ()'
: def (world ())
// Start of definition of user function 'world ()'
: rtn ("World!")
// Return value of the function
: enddef (world ())
// End of definition of user function 'world ()'
: Text hello ("Hello") & world ()
// Display the concatenation of "Hello" + "World!"
: Text str
// Poster "And have a good day!"
Function: when (cond, {instruc1 [, instruc2…]}, {instruca [, instrucb…]})
This function is useful because it simplifies writing 'if then else' conditions. If cond is true (ie
different from 0) then instruc1, etc ... will be executed, if cond is false, it will be instruca, etc ....
'When ()' returns the value of the last statement executed. It is quite similar to the function
tibasic When () but more powerful because it allows to have several instructions. However,
and only in Newprog bytecode (not in NPPTOC), when there are many instructions or when
the maximum speed is requested, it is better to use 'if then else endif' (50% faster).
Example: Ask for the respective ages of Wilfried and John, then display who is the oldest.
: init ()
: basic
: request "Wilfried's age", age1
// Enter age1 (tibasic variable)
: request "John's age", age2
// Enter age2 (tibasic variable)
: endbasic
: text when (atol (osvar (age1))> atol (osvar (age2)), {"Wilfried"}, {"John"}) & "is older"
Function: i (condition): instructions: y
This function is similar to a classic 'If: Endif' with some additional features.
If condition is true (i.e. different from 0), then the instructions will be
executed. If condition is false, will skip the instructions without executing them. This function has a
interesting because it is more concise and easier to write than a classic 'If-Endif'. Other interest
minor, you can insert an 'i (): y' in uninstantiated lists without the compiler displaying an
compilation error message unlike the classic 'If-Endif'.
CAUTION: This syntax should be used with caution. Prefer syntax as much as possible
classic 'if then endif'. In addition, with NPPTOC, the use of 'goto' and 'label' inside a
'i (): y' is forbidden on pain of crash. There is also a risk that the local variables (passed in
arguments to a function for example) are not recognized.
Example: Use in the definition of an interrupt. Displays a message if you press the
button 2 nd . Here, we could not use a classic 'If: Endif' because not tolerated between the brackets
'{}'.

Page 29
NEWPROG2 & NPPTOC
: init ()
: clrscr ()
: inter (1,1, {i (second ()), prints ("Second pressed!"), y})
: While not esc ()
: Endwhile
Function: x: instructions: y
This function is difficult to handle, is not essential and is often complicated to
read. It is especially useful when used in conjunction with the 'map ()' function because it saves
speed compared to a 'For: Endfor' loop (see 'map ()') (only in Newprog bytecode, not in
NPPTOC).
When 'x' is executed, all statements up to 'y' will be executed in one pass.
Looks like the 'i (): y' statement but unconditionally. This function has the big advantage of powers
execute several instructions just at the passage of x ''. Since 'x' is seen as a single argument,
the instructions to be executed (see examples) can be made beyond the parentheses.
Returns the value of the last instruction.
Looks like calling a function but without having to define one (interesting for large
programs because the number of user functions is limited to 30).
Limitations:
• 'x' can only be placed as the last argument of an instruction if necessary (see example).
• One cannot handle 'x', one must use it alone (raw). Example of error:
◦: text "Is minor?:" & X
◦: if age <18 then
◦ "yes" → ss
◦: else
◦ "no" → ss
◦ endif
◦ ss
// return value
◦ y
• It is forbidden to use this instruction in an uninstantiated list ('{}')
• The use of 'goto' and 'label' inside an 'x: y' is prohibited.
• The use of 'rtn ()' inside an 'x: y' is prohibited.
Example 1: Fill screen with a black sprite and display the number of sprites displayed. More
faster than with two 'For: EndFor' loops.
: init ()
: 0 → nbdisp
: seqb (sprt, xx, 1,8,1, -1)
// create the sprite (black square)
: if not sprt: finish ()
// if not enough memory then quit the program
: map (xx, 0.19 * 8.8, x)
// loop in X, 'x' is the last argument

Page 30
NEWPROG2 & NPPTOC
: map (yy, 0.12 * 8.8, x)
// loop in Y, 'x' is the last argument
: sprt8 (xx, yy, 8, sprt)
// Display a sprite
: isz (nbdisp)
// increase the sprite counter
: y
: y
: text "Nb displayed:" & string (nbdisp)
// display the number of sprites displayed
: free (sprt)
// free the memory linked to the previously created sprite
Example 2: Asks for two ages and displays which age is older
: init ()
: basic
: request "Age1", age1
// Enter age1 (tibasic variable)
: request "Age2", age2
// Enter age2 (tibasic variable)
: endbasic
: text x
// x is the last argument and is used 'raw'
: if atol (osvar (age1))> atol (osvar (age2)) then // if age1> age2
: "Older =" & osvar (age1) → ss
// return string age1 in ss
: else
: "Older =" & osvar (age2) → ss
// return string age2 in ss
: endif
: ss
// return value of x is ss (because last instruction)
y
Is equivalent to the more classic structure (which is more readable and privileged):
: init ()
: def (maxage (a1, a2))
: if a1> a2 then
// if age1> age2
: rtn ("Older =" & string (a1))
// return string age1
: else
: rtn ("Older =" & string (a2))
// return string age2
: endif
: enddef (maxage ())
: basic
: request "Age1", age1
// Enter age1 (tibasic variable)
: request "Age2", age2
// Enter age2 (tibasic variable)
: endbasic
: text maxage (atol (osvar (age1)), atol (osvar (age2)))

Page 31
NEWPROG2 & NPPTOC
Function: two (instruc1, instruc2)
This function is deprecated. It is only of rare interest with the 'map ()' function. She permits
to execute the instructions instuc1 and instruc2 in a single instruction (that of 'two ()'). The
philosophy is close to the block 'x: y' but for only 2 instructions and does not require
overflow of parentheses like the latter.
Function: lbl label_name
This function has the same role as the function of the tios. It allows you to place a label of the name
by label_name. It is to be used with the 'goto' function. Like the NewProg variable names, the
name of labels label_name must be at least 2 characters long.
Function: goto label_name
This function has the same role as the function of the tios. It allows you to jump to
the label with the same name as label_name. To be used with the 'lbl' function.
If to place in a user function 'def (): enddef ()', it will be necessary to ensure that the instruction 'lbl'
corresponding is indeed in the body of this same function.
Note that this function cannot be used in 'i (): y' and 'x: y' blocks.
Function: map (var, start, end, step, instruction)
Execute instruction by varying var from start to end with one step. This instruction is more
faster than a classic 'While: EndWhile' loop as well as 'For: Endfor' loops (except
NPPTOC). Returns the last value returned by instruction.
In Newprog bytecode (but not in NPPTOC), the use of 'map' is up to 3 times faster
as a 'For: EndFor' loop. If the need for speed is not essential, use a loop
Classic 'For: EndFor' because the code will look 'cleaner'.
Note: The end end and step step values ​​will not be re-evaluated on each iteration.
Example: Fill screen with a black sprite and display the number of sprites displayed. This code
used the 'x: y' notation. See corresponding section.
: init ()
: 0 → nbdisp
: seqb (sprt, xx, 1,8,1, -1)
// create the sprite (black square)
: if not sprt: finish ()
// if not enough memory then quit the program
: map (xx, 0.19 * 8.8, x)
// loop in X
: map (yy, 0.12 * 8.8, x)
// loop in Y

Page 32
NEWPROG2 & NPPTOC
: sprt8 (xx, yy, 8, sprt)
// Display a sprite
: isz (nbdisp)
// increase the sprite counter
: y
: y
: text "Nb displayed:" & string (nbdisp)
// display the number of sprites displayed
: free (sprt)
// free the memory linked to the previously created sprite
3-Text display functions
Function: clrscr ()
Clears the current screen and resets the text cursor to coordinates (0,0,).
C equivalent: 'clrscr ()'
Function: prints (string_ptr)
Displays on the screen (video buffer) the character string (or string) at the position of the text cursor.
C equivalent: 'printf ("% s", string_ptr)'
Example: Displays "Hello World!"
: init ()
: clrscr ()
: prints ("Hello World!")
: keywait ()
Function: printc (ascii_code)
Displays on the screen (video buffer) the character corresponding to the ascii_code as code at the position of the
text cursor.
C equivalent: 'printf ("% c", ascii_code)'
Example: Small word processing program
: init ()
: clrscr ()
: while not esc ()
: printc (keywait ())
: EndWhile

Page 33
NEWPROG2 & NPPTOC
Function: printld (value)
Displays on the screen (video buffer) the value value at the position of the text cursor.
C equivalent: 'printf ("% ld", (long) value)'
Function: setfont (text_size)
Modifies the size of the characters displayed on the screen (or buffer) to the value text_size. text_size can
take the values ​​0 (small), 1 (medium) or 2 (large). Returns the old value of the size.
C equivalent: 'FontSetSys (text_size)'
Function: newline () or nl ()
Make a carriage return of the text cursor.
C equivalent: 'printf ("\ n")'
Function: printf1 ("format", arg)
The 'printf1 ()' function is used to display on the screen window (or buffer) a text which follows a
format defined by the programmer where format is a character string that contains:
- text to be printed as is;
- a format specification that indicates how to display the arg variable provided as a parameter. This
are format codes.
Each format code begins with the symbol '%' followed by one (or two) letter (s) indicating the
display format of the corresponding arg parameter. The value of arg will replace its format code to
display.
The letter placed after the% symbol in the format code indicates the type of the parameter associated with the
format code (see below).
In Newprog, the most used format codes are:
% ld >> display a number or pointer
% s >> displays a character string (or string)
% lx >> displays a number in lowercase hexadecimal format

Page 34
NEWPROG2 & NPPTOC
% lX >> displays a number in hexadecimal format in uppercase
Note:% c% d% x% X does not work because Newprog only handles long digits.
C equivalent: 'printf ("format", arg)'
Example: Displays “One hundred: 100” on the screen
: init ()
: clrscr ()
: printf1 (“One hundred:% ld”, 100)
: keywait ()
Function: printf2 ("format", arg1, arg2)
Same as 'printf1 ()' but with two arguments.
C equivalent: 'printf ("format", arg1, arg2)'
Function: printxy (x, y, "format", arg)
Same as 'printf1 ()' with the particularity of displaying the character string at the x and y coordinates of
the screen (or the buffer).
C equivalent: 'printf_xy (x, y, "format", arg)'
Function: cwidth (ascii_code)
Returns the width in pixels of a character with ascii code ascii_code according to the size of
active character ('setfont ()' function).
C equivalent: 'FontCharWidth (ascii_code)'

Page 35
NEWPROG2 & NPPTOC
Function: moveto (x, y)
Assigns the current position of the position cursor (of the printf1 (), prints (), etc) functions to the position (x,
y)
C equivalent: 'MoveTo (x, y)'
Function: pause (string_ptr)
Displays the character string pointed to by string_ptr on a new line on the screen from the
text cursor. Wait for a key press. Returns the position of the text on a new line.
C equivalent: 'printf ("\ n% s", string_ptr); ngetchx (); '
Function: text str
Function identical to the Tibasic 'text' function.
Displays the text str in a dialog box.
Make an internal call to the 'keydisp ()' function.
Equivalent C:
long text_ (unsigned char * str)
{
unsigned char len, CESI_list [50];
CESI_list [0] = 0;
strcpy (CESI_list + 1, str);
len = strlen (str);
CESI_list [len + 2] = STR_TAG;
if (save_int_1)
{
SetIntVec (AUTO_INT_1, save_int_1);
save_int_1 = NULL;
}
TRY
cmd_text (CESI_list + len + 2);
ONERR
return 0;
ENDTRY
return 1;
}

Page 36
NEWPROG2 & NPPTOC
4-Text manipulation functions
Function: char (ascii_code)
Returns a pointer to a character string having a single character as its component
corresponding to ascii_code. The return value will be valid only if this function is not called
more than three times after this one. So remember to save the result if necessary.
Function similar to the Tibasic function of the same name.
C equivalent: sprintf (buffer, "% c", ascii_code)
// buffer = memory space of the returned character string
Example: Small word processing program
: init ()
: clrscr ()
: while not esc ()
: prints (char (keywait ()))
: EndWhile
Function: ord (char_str)
Returns the ASCII code of the character found in the char_str character string. Function
similar to the Tibasic function of the same name. This function is the inverse of the 'char ()' function.
Function similar to the Tibasic function of the same name.
Function: string (value)
Converts a value number to a character string. Returns the pointer of this string of
characters. The return value of this function will be valid until the fourth next call to
this function therefore think of making a copy if necessary (with 'newstr ()' for example). This
function is the inverse of the function 'expr ()' or 'atol ()'.
This function resembles the Tibasic function of the same name.
C equivalent: sprintf (buffer, "% ld", value);
Example: Poster: "I'm 20 years old"
: init ()
: text "I'm" & string (20) & "years old"
Function: strcat (dest_str, str)
Extend (concatenate) the string pointed to by dest_str with the string pointed to
by str. Make sure that the size of the memory space pointed to by dest is large enough to

Page 37
NEWPROG2 & NPPTOC
be able to accommodate the str. The function returns dest_str.
C equivalent: strcat (dest_str, str)
Example: Poster: "I'm 20 years old"
: init ()
: b (buff): repeat (30,0): y
: strcat (buff, "I'm")
: strcat (buff, string (20))
: strcat (buff, "years old")
: text buff
Function: strcat2 (dest_str, str) or dest_str & str
Quite similar to the 'strcat ()' function while allowing the use of the dest_str & str notation (like
in Tibasic). However, dest_str is not changed after execution of the instruction. The result of
the addition (concatenation) of the two character strings is saved in a memory space
special that will remain valid temporarily in memory. Care must be taken to ensure that the
characters generated do not exceed 50 characters under penalty of crashing the calculator. This function
is useful for displaying text on the screen. If you use this function more than twice in
the same line, the result will be distorted. So remember to regularly save the result of
return with for example the function 'newstr ()'. This function returns the pointer to the string of
characters generated.
Example: Poster: "I'm 20 years old"
: init ()
: text "I'm" & string (20) & "years old"
Function: strcmp (str1, str2)
Compare the contents of the two str1 and str2 strings with each other. The 'strcmp ()' function
start with the first character in each character string and move on to the next character and
so on until a character differs or the end of the character string is reached.
'strcmp ()' returns the following values:
• <0 if str1 is less than str2
• == 0 if str1 is the same as str2
•> 0 if str1 is greater than str2
Specifically, if the strings differ, the value of the first character that differs from
str2 minus the corresponding character in the string str1 is returned.
C equivalent: strcmp (str1, str2)

Page 38
NEWPROG2 & NPPTOC
Function: direct_str = str2
Compare the explicit string (written directly) direct_str with the string
str2 (explicit or not). If both strings have the same content, then returns 1.
Also-no returns 0.
Equivalent C:
if (strcmp (direct_str, str2) == 0) return 1;
else return 0;
Example: If the character string entered by the user is "john", then displays "Hello
John ". Also-no, displays" Hello stranger "
: init ()
: basic
: request "Enter your name", namestr
: endbasic
: if "john" = osvar (namestr) then
: text "Hello john"
: else
: text "Hello stranger"
: endif
Function: sprintf (buffer, formated_str, data)
This function writes text according to a certain format (data data in
formated_str) from a buffer memory space. Make sure that buffer receiving
data is large enough to accommodate the requested content. The behavior of
this function is similar to the 'printf1 ()' function except that it returns its result in
a character string (buffer) rather than displaying it.
Returns the size of the character string thus created (without the final '\ 0').
C equivalent: sprintf (buffer, formated_str, data)
Example: Poster "9 + 10 = 19"
: init ()
: b (buff): repeat (10,0): y
: sprintf (buff, "9 + 10 =% ld", 9 + 10)
: text buff

Page 39
NEWPROG2 & NPPTOC
Function: strcpy (buff, src)
Copy a character string pointed to by src to the memory space pointed to by buff. The character
0 at the end of the character string is also copied. The function returns buff. Note: If the chains of
characters pointed to by src and buff overlap in memory, behavior is undefined.
'strcpy ()' considers dest to be a large enough memory space to accommodate src.
C equivalent: strcpy (buff, src)
Example: Newprog code equivalent of the Newprog 'newstr ()' function
: init ()
: def (newstr2 (str, vardest))
: malloc (strlen (str) +1) → vardest
: strcpy (vardest, str)
: enddef (newstr2 ())
Function: gets (buffer)
Retrieves a character string entered on the keyboard until the ENTER key is pressed.
pressed and copy to buffer. The space key is supported.
Make sure that the memory space pointed to by buffer is large enough to avoid a crash.
C equivalent: gets (buffer)
Example: Asks for your name and displays "Hello XXXX"
: init ()
: b (buff): repeat (20,0): y
: clrscr ()
: prints ("Enter your name:"): nl ()
: gets (buff)
: text "Hello" & buff
Function: strlen (string)
Returns the length in characters of the string. The null character at the end of string
is not counted. This function is very useful.

Page 40
NEWPROG2 & NPPTOC
Function: expr (string) or atol (string)
Converts the string string to a number and returns that number. Similar to expr () du
Tibasic but only take strings or string pointers as arguments (with a possible
+/- or spaces). These functions are the inverse of the 'string ()' function.
C equivalent: atol (string)
5-Graphic functions
Function: clrlcd ()
Clears the current video memory. This function does not affect the position of the text cursor
as does the 'clrscr ()' function. It can be used to do grayscale. She is
slightly faster than the 'clrscr ()' function.
Function: gmode (gmode)
Selects the display mode for all graphics functions. Returns the old value of
graphics mode. The different possible values ​​of gmode are:
0 = gor: classic mode OR - Default
1 = gerase = greplace: Erase mode - Replacement mode for sprite functions
2 = gxor: XOR mode >> inverts the state of the pixels
3 = gand: AND mode - Only for sprite functions - Allows you to hide
Function: setlcd ( video_memory_address )
Specifies the position of the video memory. All graphics functions will apply to the screen
graphic pointed to by video_memory_address. The default value is 0h4C00 if the levels of
gray have not been activated. If video_memory_address is different from 0h4c00, the graphics
completed will not be visible. You will need to copy the contents of the video memory pointed to by
video_memory_address to the address 0h4c00 to view them (with
memcpy (0h4c00, video_memory_address, lcdsize)). This function is used (among others) when
we do not want to visualize the construction of an image, but only the result (it is the
method called "double buffering", it is often used in advanced 2D games). It is necessary
make sure to restore the initial address before exiting the program. This function returns
the old graphics memory address.

Page 41
NEWPROG2 & NPPTOC
Equivalent C:
unsigned char * setlcd (video_memory_address)
{
unsigned char * old_lcdmem;
old_lcdmem = * lcdad_ptr;
// lcdad_ptr being the current video pointer
PortSet ((* lcdad_ptr = video_memory_address), 239, 127);
return old_lcdmem;
}
Example: Displays the sequence of the first 185 positive integers without viewing their "plots"
: init ()
: setfont (0)
// Small text font
: malloc (lcdsize) → scrbuff
// New graphics area
: if not scrbuff: finish ()
: clrscr ()
: prints ("Drawing in progress ...")
: getlcd () → video
// Get the pointer of the visible graphics area (= 0h4c00)
: setlcd (scrbuff)
// Assign the plots for the new graphics area
: clrscr ()
: for vv, 1,185,1
: printf1 ("% ld", vv)
// Perform the traces
: endfor
: memcpy (video, scrbuff, lcdsize)
// Copy the “filled” graphics area into the visible graphics area
: keywait ()
: setlcd (video)
// Reassign the paths in the visible area (by default)
: free (scrbuff)
Function: getlcd ()
Returns the address of the current video memory (By default, = 0h4c00 if the gray levels are not
not activated).
Function: drawpic (x, y, pic_str)
Display at coordinates (x, y) the Tibasic bitmap image whose name is pic_str (dir \ file). The mode
display is defined with the 'gmode ()' function. This function is close to the Tibasic functions
such as rplcpic and rclpic. Returns 0 if an error occurred, 1 also-no.

Page 42
NEWPROG2 & NPPTOC
Function: getpic (x1, y1, x2, y2, pic_str)
Save the content of the screen between points (x1, y1) and (x2, y2) in the Tibasic pic_str variable.
Returns the size in bytes of the created file. Rather similar to the Tibasic stopic function, however
the ability to reach the entire screen. This function is slow. This function returns 0 if the space
memory runs out.
Function: sprt8 (x, y, h, sprite)
Displays the sprite (8 bits horizontal) sprite with the upper corner at point (x, y) and a height of
sprite of h lines. In the case where x or and y are negative, the pixels outside the window
(0,0,239,127) will not be processed. 'sprt8 ()' displays around 6000 sprites per second. See
'gmode ()' for the possible display modes.
Example: Display in the center of the screen a sprite which represents a square
: init ()
: b (sprt)
: 0b11111111
: 0b10000001
: 0b10000001
: 0b10000001
: 0b10000001
: 0b10000001
: 0b10000001
: 0b11111111
: y
: clrlcd ()
: sprt8 (76,46,8, sprt)
: keywait ()
Function: sprt82 (x, y, h, sprite)
'sprt82 ()' is a variant of 'sprt8 ()'. It is used to manage collisions. Unlike 'sprt8 ()',
it will return a non-zero value if at least one active pixel of the sprite sprite has collided
with a pixel on the screen when it is displayed (also-no will return 0). If collision, the sprite, will not be
not displayed and the function will return a pointer to a list of double-byte numbers
each (valid until the next call to a 'sprtX2 ()' function). The first item in this list
will be equal to the height where the detected collision took place. The second element will be equal to the
sprite value (at the height returned as the first element). This value is used to give a
indication of the position of the collision (s). For example, if this value is negative, it is
that there has been a collision with the leftmost bit (at the specified height). If the value is equal to 1, it
there was a collision only on the bit furthest to the right. To retrieve these values, it is interesting
first use the 'settype ()' function to be able to use the [] notation. Also no,

Page 43
NEWPROG2 & NPPTOC
the use of 'lb (pointer_to_the_list, element)' can be used. See 'gmode ()' for modes
display possible.
Example: See the analogous function 'sprt162 ()'
Function: sprt16 (x, y, h, sprite)
Displays the sprite (16 bits horizontal) sprite with the upper corner at point (x, y) and a height of
sprite of h lines. In the case where x or and y are negative, the pixels outside the window
(0,0,239,127) will not be processed. 'sprt16 ()' displays around 5000 sprites per second. See
'gmode ()' for the possible display modes.
Example: Displays a 16x4 pixel filled rectangle on the screen
: init ()
: seqw (sprite, vv, 1,4,1, -1)
// We could also use the syntax 'w (sprite): repeat (4, -1): y'
: clrlcd ()
: sprt16 (72,48,4, sprite)
: keywait ()
: free (sprite)
Function: sprt162 (x, y, h, sprite)
'sprt162 ()' is a variant of 'sprt16 ()'. Unlike 'sprt16 ()', it will return a non
null if at least one active pixel of the sprite sprite has collided with a pixel on the screen during
its display (also-no will return 0). If collision, the sprite will not be displayed and the function
will return a pointer to a list of numbers coded on two bytes each (valid until
next call of a function 'sprtX2 ()'). The first item in this list will equal the height
where the detected collision took place. The second element will be equal to the value of the sprite (at the
height returned as first element). This value is used to give an indication of the position
of the collision (s). For example, if this value is negative, there has been a collision with the
leftmost bit (at the specified height). If the value is equal to 1, there has been a collision only
on the rightmost bit. To retrieve these values, it is interesting to first use the
'settype ()' function to be able to use the [] notation. Also, the use of
'lw (pointer_to_list, item)' can be used. See 'gmode ()' for display modes
possible.
Example: Display a route and use the keys to move a sprite if it does not fit in
collision. If collides, displays return information from 'sprt162 ()'.
: init ()
: w (sprt)
: repeat (6,0b0001110001110000)

Page 44
NEWPROG2 & NPPTOC
: 0b1100000000000011
: 0b1111111111111111
: repeat (8,0b1100110011110011)
: y
: clrscr ()
: 40 → yy
: 80 → xx
: 0 → nc
: settype (rr, 2)
: gmode (2)
: fillrect (0,0,40,127)
: fillrect (160-40,0,160,127)
: fillrect (0,0,160,10)
: fillrect (0,95,160,100)
: dline (50,0,40,100)
: dline (110,0,120,100)
: dline (60,0,60,30)
: dline (60,99,65,80)
: sprt16 (xx, yy, 16, sprt)
: While gkey ()! = Esc
: wait (5)
// To slow down the movement
: isz (inc)
: if leftt () Then
: sprt16 (xx, yy, 16, sprt)
: if sto (rr, sprt162 (dsz (xx), yy, 16, sprt)) Then
: sprt16 (isz (xx), yy, 16, sprt)
: EndIf
: EndIf
: if rightt () Then
: sprt16 (xx, yy, 8, sprt)
: if sto (rr, sprt162 (isz (xx), yy, 16, sprt)) Then
: sprt16 (dsz (xx), yy, 16, sprt)
: EndIf
: EndIf
: if up () Then
: sprt16 (xx, yy, 16, sprt)
: if sto (rr, sprt162 (xx, dsz (yy), 16, sprt)) Then
: sprt16 (xx, isz (yy), 16, sprt)
: EndIf
: EndIf
: if down () Then

Page 45
NEWPROG2 & NPPTOC
: sprt16 (xx, yy, 16, sprt)
: if sto (rr, sprt162 (xx, isz (yy), 16, sprt)) Then
: sprt16 (xx, dsz (yy), 16, sprt)
: EndIf
: EndIf
: if rr Then
: printxy (0,0, "height =% ld", rr [0])
: printxy (70,0, "value =% ld", rr [1])
: Else
: EndIf
: EndWhile
Function: sprt32 (x, y, h, sprite)
Displays the sprite (32-bit horizontal) sprite with the upper corner at point (x, y) and a height of
sprite of h lines. In the case where x or and y are negative, the pixels outside the window
(0,0,239,127) will not be processed. 'sprt16 ()' displays around 5000 sprites per second. See
'gmode ()' for the possible display modes.
Function: sprt322 (x, y, h, sprite)
'sprt322 ()' is a variant of 'sprt32 ()'. Unlike 'sprt32 ()', it will return a non
null if at least one active pixel of the sprite sprite has collided with a pixel on the screen during
its display (otherwise it will return 0). If collision, the sprite will not be displayed and the function
will return a pointer to a list of four-byte numbers (this pointer is valid
until the next call to a 'sprtX2 ()' function). The first element of this list will be equal to the
height where the detected collision occurred. The second element will be equal to the value of the sprite
(at the height returned as the first element). This value is used to give an indication of the
position of the collision (s). For example, if this value is negative, there has been
collision with the leftmost bit (at the specified height). If the value is equal to 1, there has been
collision only on the rightmost bit. To retrieve these values, it is interesting to use
first the 'settype ()' function to be able to use the [] notation. Also, the use of
'll (pointer_to_list, element)' can be used. See 'gmode ()' for display modes
possible.
Example: See analog 'sprt162 ()'
Function: g sprt8 (x, y, h, sprite_dest)
Copy a sprite 8 pixels wide (either a byte or byte) and h lines high from the screen to
position x and y and save it in the sprite_dest buffer. Make sure that the sprite_dest buffer
be large enough to avoid crashing the calculator. The buffer can be created with 'malloc ()' or
'b (): y' for example.

Page 46
NEWPROG2 & NPPTOC
Function: g sprt16 (x, y, h, sprite_dest)
Copy a sprite 16 pixels wide (either two bytes or bytes) and h lines high from
the screen at the x and y position and saves it in the sprite_dest buffer. Make sure that the buffer
sprite_dest is large enough to avoid crashing the calculator. The buffer can be created with
'malloc ()' or 'w (): y' for example.
Function: g sprt32 (x, y, h, sprite_dest)
Copy a sprite 32 pixels wide (either four bytes or bytes) and h lines high from
the screen at the x and y position and saves it in the sprite_dest buffer. Make sure that the buffer
sprite_dest is large enough to avoid crashing the calculator. The buffer can be created with
'malloc ()' or 'l (): y' for example.
Function: g sprt8x (x, y, h, byte_width, sprite_dest)
The 'gsprt8x ()' function differs from the sprite recovery functions seen above in that
that it allows you to retrieve sprites with a configurable width in bytes (byte_width variable).
'gsprt8x ()' retrieves a sprite from the active screen at x and y coordinates and saves it to the
buffer pass as sprite_dest argument. This function is much faster to save
a portion of the screen as the 'getpic ()' function. X and y being the coordinates of the upper corner
left of the sprite to be recovered. h is the height in pixels of the sprite. Make sure that the buffer of
destination is large enough to avoid crashes. To display the recovered sprite, use the
function 'sprt8x ()'. In the particular cases where byte_width is equal to 1 or 2 or 4, the functions
'sprt8 ()', 'sprt82 ()', 'sprt16 ()', etc ... can be used. The data of the recovered sprite is
organized as follows (for byte_width = 3): line1 / byte1, line1 / byte2, line1 / byte3,
line2 / byte1, line2 / byte2, line2 / byte3 etc. As the function is not clipped, take care not to leave the
screen frame.
Example: Fills the screen with the copy of the upper left quarter of the initial screen
: init ()
: malloc (10 * 50) → sprt
: gsprt8x (0,0,50,10, sprt)
// Capture the upper left corner
: clrscr ()
: sprt8x (0,0,50,10, sprt)
// Display in the upper left corner
: sprt8x (10 * 8,0,50,10, sprt)
// Display in the upper right corner
: sprt8x (0,50,50,10, sprt)
// Display in the lower left corner
: sprt8x (10 * 8,50,50,10, sprt)
// Display in the lower right corner
: keywait ()
: free (sprt)

Page 47
NEWPROG2 & NPPTOC
Function: sprt8x (x, y, h, byte_width, sprite)
This function is made to be used with the 'gsprt8x ()' function. The 'sprt8x ()' function differs
classic sprite display functions by the fact that it allows to display sprites of a
configurable width in bytes (byte_width variable). 'sprt8x ()' displays the sprite sprite on the active screen
at x and y coordinates, with a pixel height of h pixels .. The function not being clipped,
make sure to display the entire image in the frame of the screen otherwise it will crash. The trends
display are defined with the 'gmode ()' function.
Function: gsprt (w, h, bitmap_str, sprtdest)
Create a sprite of w bytes wide (w = 1 or 8; 2 or 16; 4 or 32) and h rows high to
from the Tibasic image (PIC type) bitmap_str. On output, sprtdest points to the sprite thus created.
You must run 'free (sprtdest)' before the program ends if you don't want to lose
unnecessary memory. It is important that bitmap is an actual width of w to
correctly transcribe the image. The great advantage of this function is to be able to use the
sprite functions later which are much faster than displaying a
bitmap image.
Example: Create the pp sprite from an image named 'bitmap' that the user has previously
created (necessarily 8x8 pixels wide) and displays this sprite in the center of the screen.
: Init ()
: clrscr ()
: gsprt (8.3, ”bitmap”, pp)
: sprt8 (50,50,3, pp)
: free (pp)
: keywait ()
Function: dline (xa, ya, xb, yb)
Displays a character line on the screen between point (xa, ya) and (xb, yb). The line must be
entirely contained in the window (0,0,239,127). Otherwise, the calculator will crash.
Function: dmline (list_of_x, list_of_y, num_pts)
Draw a first line then a second with the last point of the first line and so on
after. The lines will be drawn from the first elements of the lists to num_pts
elements of the lists list_of_x and list_of_y. In total, there are num_pts-1 lines.
Example: Draw a centered rectangle
: init ()

Page 48
NEWPROG2 & NPPTOC
: b (lx)
: 20
: 140
: 140
: 20
: 20
: y
: b (ly)
: 20
: 20
: 80
: 80
: 20
: y
: clrscr ()
: dmline (lx, ly, 5)
: keywait ()
Function: dcircle (xc, yc, radius)
Displays a center circle (xc, yc) with a radius equal to radius. See 'gmode ()' for the mode
display. The coordinates of the center of the circle must be included in the window frame
graphic.
Function: fillcirc (xc, yc, radius)
fDraw a circle filled with center (xc, yc) with a radius equal to radius. See 'gmode ()' for the mode
display. The coordinates of the center of the circle can be outside the graphics window (the
function is clipped).
Function: dpix (x, y)
Draws a pixel on the screen at coordinates (x, y). The display mode is selected as with
all graphics functions using the 'gmode ()' function.
Function: gpix (x, y)
Returns the state of the pixel pointed to by x and y: 1 if on 0 if off.

Page 49
NEWPROG2 & NPPTOC
Function: fillrect (xa, ya, xb, yb)
Draw a filled rectangle between the points (xa, ya) and (xb, yb). Display mode is selected
with the 'gmode ()' function.
Function: grayon ()
Activates gray levels (4 levels). This function disables the display dialog boxes
error and reactivate the value the next time 'grayoff ()' is called.
C equivalent: GrayOn ()
Example: See 'light ()' function
Function: grayoff ()
Disables gray levels (4 levels).
C equivalent: GrayOff ()
Example: See 'light ()' function
Function: light ()
Activates the light gray plane. The grayon () function must have been executed previously. This
function assigns the address of the video memory to the 'light' plane.
Example: Display a rectangle in light gray and a rectangle in dark gray. Their intersection will be
black.
: init ()
: grayon ()
// Activate the gray levels
: light ()
// Select the light gray plane
: fillrect (10,10,90,90)
// First full rectangle
: dark ()
// Select the dark gray plane
: fillrect (70,20,150,80)
// Second full rectangle
: keywait ()
: grayoff ()
// Disable grayscale mode

Page 50
NEWPROG2 & NPPTOC
Function: dark ()
Activates the dark gray plane. The grayon () function must have been executed previously. This
function assigns the video memory address to the 'dark' plane.
Example: See 'light ()' function
Function: drawstr (x, y, str)
Displays at coordinates (x, y), the string str. This function does not affect the cursor
position of the text (functions 'prints ()', ...).
Function: savescr (index)
Saves video memory in the memory space specified by the index index and returns a
pointer to this memory space. If the memory space specified by index was already occupied,
'savescr ()' will free the memory space of the old screen saver before copying the current screen
(always referenced by index). NewProg will automatically delete screen saves at the end
of the execution of the program. You can however free it by yourself with the function
free. To be used with the 'loadscr ()' function. Index can only take the following values: 0,1,2,3.
This function returns 0 if the memory space runs out.
Function: loadscr (index)
Displays the pre-recorded image referenced by the index index on the screen (use with 'savescr ()').
More precisely, this copies the image to the current video memory ('setlcd ()', 'getlcd ()' ...). She can
be used for grayscale. Returns a pointer to the memory space that has been
copied to the screen.
Example: Save, erase and restore the screen
: init ()
: savescr (0)
: text ”Screen saved”
: clrscr ()
: text ”Screen cleared”
: loadscr (0)
: text ”Screen restored”
Function: lcdup ()

Page 51
NEWPROG2 & NPPTOC
Increase the contrast by 1. Returns the new value of the contrast level.
Function: lcddown ()
Decreases the contrast by 1. Returns the new value of the contrast level.
Function: prettyxy (x, y, expr_str)
Print as "pretty print" (as in the home screen) at coordinates (x, y) the expression
expr_str (string). Returns 0 if the expression str_expr contains an error, 1 also-no.
Example: See function 'getwbt ()'
Function: getwbt ( expr_str, width_dest_var, bottom_dest_var, top_dest_var )
Returns information relating to the size of a block displayed on the screen using the function
'prettyxy ()'. The information will be saved in the three variables width_dest_var (width
in pixel), bottom_dest_var (lowest ordinate), top_dest_var (highest ordinate).
Example: Display an expression in the upper left corner, in the center of the screen and in the corner
lower lower.
: init ()
: clrscr ()
: "sin (7 * x ^ 2 + y)" → ex
: getwbt (ex, ww, bb, tt)
: prettyxy (0,0 + tt, ex)
: prettyxy (80-ww / 2.49, ex)
: prettyxy (159-ww, 99-tt + bb, ex)
: keywait ()
Function: lscroll (num_line)
Translates 1 pixel to the left of num_line lines from the address of the
video memory with a width of 160 pixels. It may be useful to change the memory address
video to obtain the desired effect ('setlcd ()' function).

Page 52
NEWPROG2 & NPPTOC
Function: rscroll (num_line)
Translates 1 pixel to the right of num_line lines from the address of the
video memory with a width of 160 pixels. It may be useful to change the memory address
video to obtain the desired effect ('setlcd ()' function).
Function: uscroll (num_line)
Translates 1 pixel up num_line lines from the address of the
video memory with a width of 160 pixels. It may be useful to change the memory address
current video to obtain the desired effect ('setlcd ()' function).
Function: bscroll (num_line)
Translates 1 pixel down num_line lines from the address of the
video memory with a width of 160 pixels. It may be useful to change the memory address
current video to obtain the desired effect ('setlcd ()' function).
Function: lscroll2 (num_line)
Translates 1 pixel to the left of num_line lines from the address of the
video memory with a width of 240 pixels. It may be useful to change the memory address
video to obtain the desired effect ('setlcd ()' function).
Function: rscroll2 (num_line)
Translates 1 pixel to the right of num_line lines from the address of the
video memory with a width of 240 pixels. It may be useful to change the memory address
video to obtain the desired effect ('setlcd ()' function).
Function: uscroll2 (num_line)
Translates 1 pixel up num_line lines from the address of the
video memory with a width of 240 pixels. It may be useful to change the memory address
current video to obtain the desired effect ('setlcd ()' function).

Page 53
NEWPROG2 & NPPTOC
Function: bscroll2 (num_line)
Translates 1 pixel down num_line lines from the address of the
video memory with a width of 240 pixels. It may be useful to change the memory address
current video to obtain the desired effect ('setlcd ()' function).

Page 54
NEWPROG2 & NPPTOC
6-Keyboard functions
Function: keywait ()
Stop the execution of the program and wait for a key to be pressed. Then return the number
of the pressed key. The value is comparable to the getkey () function of Tibasic (see function
'gkey ()' for the code of the most common keys). Constants have been defined to avoid
having to memorize the code of the most common keys. (Make an internal call from the
'keydisp ()' function).
C equivalent: ngetchx ()
Function: gkey ()
'gkey ()' is the most flexible function to use to test if a key is pressed without forcing
stop the program during its execution. Return the same code as the 'keywait ()' function.
Similar to the Tibasic getkey function. 'keyclear ()' must not have been executed previously
so as not to interfere with this function. For this function, predefined constants can
be used (see example below).
Key codes:
TI-89: Key
Normal
+ Shift
+ 2nd
+ Diamond
+ alpha
Up
337
8529
4433
16721
33105
Right
344
8536
4440
16728
33112
Down
340
8532
4436
16724
33108
Left
338
8530
4434
16722
33106
TI-92 +: Key
Normal
+ Shift
+ 2nd
+ Diamond
+ alpha
Up
338
16722
4434
8530
33106
Right
340
16724
4436
8532
33108
Down
344
16728
4440
8536
33112
Left
337
16721
4433
8529
33105
Equivalent C:
long gkey (void)
{

Page 55
NEWPROG2 & NPPTOC
unsigned short key;
kbq = kbd_queue ();
if (! OSdequeue (& key, kbq))
{
return key;
}
return 0;
}
Example: Press the top key and the '2 nd ' key at the same time
: init ()
: clrscr ()
: prints (“press up + second to exit”)
: while gkey ()! = up + second
: endwhile
Function: gets (buffer)
Retrieves a character string entered on the keyboard until the ENTER key is pressed.
pressed and copy to buffer. The space key is supported. Return buffer.
C equivalent: gets (buffer)
Function: keydelay (delay)
Assigns the initial automatic key repeat delay to the delay value for the 'keywait ()' and
'gkey ()'. The measurement time is 1/395 s. The default is 336 (slightly shorter than
a second). The minimum delay value is 3. Returns the previous delay.
C equivalent: OSInitKeyInitDelay (delay)
Function: keyspeed (rate)
Assigns the auto key repeat rate to the value rate for the 'keywait ()' and 'gkey ()' functions.
The measurement time is 1/395 s. The default is 48. Returns the previous rate.

Page 56
NEWPROG2 & NPPTOC
C equivalent: OSInitBetweenKeyDelay (rate)
Function: keytest (row, column_mask)
'keytest ()' is a low level function to know if one or more keys are pressed
simultaneously. For the most common keys, it is easier to use the 'up ()' functions,
'down ()', 'second ()', etc ... This function can be used if 'keyclear ()' has been previously
executed. See examples for operation.
TI-89:
Column
R
o
w
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1
Bit 0
Bit 0 alpha Diamnd Shift
2nd
Right Down
Left
Up
Bit 1
F5
CLEAR
^
/
*
-
+
ENTER
Bit 2
F4
BckSpc
T
,
9
6
3
(-)
Bit 3
F3
CATLG
Z
)
8
5
2
.
Bit 4
F2
FASHION
Y
(
7
4
1
0
Bit 5
F1
HOME
X
=
|
EE
STO
APPS
Bit 6
ESC
TI-92 Plus:
Column
R
o
w
Bit 7
Bit 6
Bit 5 Bit 4 Bit 3 Bit 2
Bit 1
Bit 0
Bit 0 Down
Right
Up
Left
Hand
Shift Diamnd
2nd
Bit 1
3
2
1
F8
W
S
Z
Bit 2
6
5
4
F3
E
D
X
Bit 3
9
8
7
F7
R
F
VS
STO
Bit 4
,
)
(
F2
T
G
V
Space
Bit 5 TAN
COS
INS
F6
Y
H
B
/

Page 57
NEWPROG2 & NPPTOC
Bit 6
P
ENTER2
LN
F1
U
J
NOT
^
Bit 7
*
APPS CLEAR
F5
I
K
M
=
Bit 8
ESC
FASHION
+
O
L
θ
BckSpc
Bit 9
(-)
.
0
F4
Q
AT
ENTER1
-
C equivalent: _rowread_inverted (row) & _ rowread_inverted (row) & column_mask
Example 1: Test if the CLEAR key is pressed
On TI89:
: keytest (0b10,0b1000000)
On TI92:
: Keytest (0b10000000,0b100000)
Example 2: Tests whether the Left and Up keys have been pressed simultaneously (for a Ti89). Return
a non-zero number if at least one of the two keys has been pressed. Test keys on the same
column
: init ()
: pause "Press Up and left simultaneously"
: while not esc ()
: if keytest (1,0b11) = 3 then // if you want to test the left key only (on ti89), write if keytest (1,0b10)
: prints ("Up and Left pressed")
: endif
: endwhile
: pause "Finish"
Function: keyclear ()
Allows you to not display on the screen the status of the alpha, second, upper case or diamond keys. In
using this function, the 'keywait ()' and 'pause ()' functions are to be avoided because they will restore
automatically display the status of the keys. To do this, use the other key test functions
what are 'keytest' and other functions 'up ()', 'down ()', 'second ()', .... The 'gkey ()' function does not
will not work if 'keyclear ()' has been started. See the 'keydisp ()' function to restore the display of
key state as well as to be able to reuse functions such as 'gkey ()'. Another
interesting feature of this function is that it avoids the observed slowing down of
the calculator (around 25%) as soon as a key is pressed
Equivalent C:

Page 58
NEWPROG2 & NPPTOC
void keyclear (void)
{
if (save_int_1 == NULL)
{
save_int_1 = GetIntVec (AUTO_INT_1); SetIntVec (AUTO_INT_1,
DUMMY_HANDLER);
}
}
Function: keydisp ()
Reactivates the display of the status of the keys. Use if you executed 'keyclear ()'
previously.
Equivalent C:
void keydisp (void)
{
if (save_int_1)
{
SetIntVec (AUTO_INT_1, save_int_1);
save_int_1 = NULL;
}
}
Functions: up () down () leftt () rightt () second () shiftt ()
diamond () alpha () esc ()
Tests whether the corresponding up, down, left, right, 2nd, upper case, diamond or alpha key has been
pressed during the time that the function has been executed. The function does not stop
program execution.

Page 59
NEWPROG2 & NPPTOC
7-Tibasic functions
Function: os (string)
'os ()' executes string as a Tibasic command. Can only return an integer or pointer
on character string. List and floating point return is not yet implemented
(do it manually with the 'fopen ()' function). Please note, the data is temporary and must
be saved so as not to lose them. This function is slow (approximately 33 calls per second).
This function is useful for executing Tibasics instructions dynamically or for
simplify the writing of a 'basic: endbasic' sequence.
Example: Returns xx ^ 3, by first assigning xx to the value 2
: init ()
: clrscr ()
: 2 → osvar (xx)
: printf1 ("xx ^ 3 =% ld", os ("xx ^ 3"))
: keywait ()
Function: osvar (tibasic_var) or osvar (direct_tibasic_var_str )
This function can be used to read a Tibasic variable or to write to a variable
Tibasic. The Tibasic variable has an explicit name tibasic_var or an explicit name written between ""
(direct character string direct_tibasic_var_str) and must consist of at least two
characters (use the 'os ()' function otherwise):
• Read: Returns the value of a Tibasic variable. This function is faster than the
'os ()' function (1300 calls per second). 'osvar ()' will return a number if var_string is a
expression, or a pointer to character string if var_string is of type string. In the
case where 'osvar ()' returns a pointer to character string, it may be necessary to
save the character string in a memory space ('strcpy ()', 'newstr ()' functions,
etc ...) because the pointer returned by 'osvar ()' is temporary. System variables cannot
not be recover with this function. Then use the 'os ()' function.
• Write: Combined with the notation '→' to write in a Tibasic variable (see the
function 'toos ()' also). A description with additional information is present
in the Memory Functions section ('→' or 'sto ()')
Example: Display the character string "Hello World!" and the number 666
: init ()
: "Hello World!" → osvar (hellostr)
: 666 → osvar ("num")

Page 60
NEWPROG2 & NPPTOC
: text osvar ("hellostr")
: text string (osvar (num))
Function: toos (tibasic_var_str, entity)
This function is similar to writing 'entity → osvar (tibasic_var_str)' (section Functions
Memory). This function returns 0 if the memory space runs out. As a reminder, the content
of the created variable depends on the entity argument. Here are the possible cases:
• Entity is a number (or return of any function), then the variable creates
will be of type EXPR.
• Entity is an explicitly written character string, then the created variable will be
a string of type STR.
• Entity is written in the form #pointer. 'pointer' will be considered as a pointer
on character string and the variable created will be of type STR and will be assigned to the
content of the pointed character string.
Function: seqe (tibasic_var_dest_string, var, start, end, step, instruction)
Creates a Tibasic list composed of numeric values ​​whose name is tibasic_var_dest (see its
peer 'seqs ()' for creating a list of strings). The content of this list
will consist of (end-start) / step elements. The first element of this list will be the returned value
by executing an instruction for a value of the variable var equal to start. The second element
will equal the result for var = var + step. And so on for the following items. This function
allows you to create Tibasic lists with variable elements. Returns the number of elements in the list.
This function returns 0 if the memory space runs out.
Example: Poster "{1,2,3,4,5}"
: init ()
: seqe ("x", vv, 1,5,1, vv)
: basic
: clrio
: pause x
Function: seq s (tibasic_var_dest_string, var, start, end, step, instruction)
Create a Tibasic list composed of strings whose name is tibasic_var_dest (see its
peer 'seqe ()' for creating a list of numeric values). The content of this list
will consist of (end-start) / step elements. The first element of this list will be the string of
characters returned by the instruction execution for a value of the variable var equal to start. The
second element will be the result for var = var + step. And so on for the following items.
Returns the number of elements in the list. This function returns 0 if the memory space comes to
to lack.

Page 61
NEWPROG2 & NPPTOC
Example: Asks to choose a directory in a menu and displays the names of the files contained
and return the path of the selection
: init ()
: reps (rep) → nbreps
: seqs ("replist", vv, 1, nbreps, 1, rep [vv-1])
: basic
: popup replist, x
: endbasic
: os ("x") - 1 → repsel
: files (file, rep [repsel]) → nbfiles
: seqs ("filelist", vv, 1, nbfiles, 1, file [vv-1])
: basic
: popup filelist, x
: endbasic
: os ("x") - 1 → filesel
: clrscr ()
: pause "File selected:" & rep [repsel] & "\" & file [filesel]
: free (file)
: free (rep)
: basic
: delvar replist, filelist, x
Function: fopen (filename_str)
Copy into memory the contents of the file filename_str (with the first two bytes of size in
memory). See appendix for more details on the structure of a file. The memory space created
must be freed before the end of the execution of the program to avoid memory loss ('free ()'. If
the file already exists, it will be overwritten. If the file does not exist, returns 0.
Function: fcreate (data_ptr, file_dest_str)
Copies the contents of a memory block to a file. You can thus create Tibasic files from
all types. See Appendix to understand the structures of the most common Tibasic files. The
size (subtracted from 2) of the memory block must be recorded on the first two bytes of this
memory block (thanks to the 'wb ()' function for example). Returns 1 if perform successfully, also-
no returns 0.
Example: Create the Tibasic variable named "hello" of type STR containing "Hello World"
: init ()

Page 62
NEWPROG2 & NPPTOC
: malloc (20) → ptr
// Create a sufficiently large temporary memory space
: "Hello world" → ss
: strcpy (ptr + 3, ss)
// Copy the content of ss into the appropriate memory area
: wb (ptr, 2 + 1 + strlen (ss) + 1.0h2d)
// Assign the type (0h2d corresponds to the STR type)
: wb (ptr, 2,0)
// Write '0' in the third byte (mandatory for the STR type)
: ww (ptr, 0, strlen (ss) + 1 + 1 + 1)
// Write the size first
: fcreate (ptr, "hello")
// Create the file
: free (ptr)
Function: open ( {filetag1, filetag2, ..., 0} )
Opens an Open dialog box. Opens a dialog box asking to choose a type of
file among {filetag1, filetag2, etc}. If the user wants to select files of types
customized, or derived from the OTH type (such as NPP files for example), it must place the
type othtag as element of the list followed by a character string containing the name of the type
personalized. For example, if you want to display NPP type files (extension of
Newprog executables) as well as the images (pictag), the command will be as follows:
open ({othtag, ”NPP”, pictag}) Once the file type has been selected, the user can select
a directory among those available on the calculator. In the end, the user selects a file
among those proposed, which correspond to the directory and the type of file selected
previously. The user validates his choice by pressing ok. This function is limited to
following types of files: STR, LIST, TEXT, ASM, OTH (NPP, etc ...) and PIC. Before launching this
function, make sure that the grayscale is not active otherwise it will crash. Function
returns a character string containing the selected file (valid until the next call
function). If the user has pressed the ESC key or if the file does not exist, the function
returns an empty string.
Example: Asks to select a file among the TEXT and PIC types and displays its path
: init ()
: open ({texttag, pictag}) → filestr
: text filestr
Function: isarchi (var_str)
Returns 1 if the file identified by the var_str character string is archived, 0 if it is not
archived. Return -1 if the file does not exist.
Function: archi (var_str)
Archive a file. Similar to the Tibasic archive function but taking as argument a
filename as a string (var_str). It nevertheless allows a writing
more concise. Returns 1 on success. Returns 0 if the archive memory runs out.

Page 63
NEWPROG2 & NPPTOC
Function: unarchi (var_str)
Unarchives a file. Similar to the Tibasic unarchiv function but taking as argument the
filename as a string (var_str). It nevertheless allows a writing
more concise. Returns 1 on success, 0 also-no.
Function: files (dest_direct_var, rep_str)
This function allocates a memory space whose pointer will be saved in the variable
dest_direct_var and save in this space all the file names present in the directory
rep_str. Assigns the type of dest_direct_var to 10 (see typings), so filenames are
spaced 10 bytes apart in memory. The notation [] can then be used. This function
returns the number of file names recovered. The number of file names returned is
limited to 80. This function returns 0 if the memory space runs out.
Example 1: Display all the file names present in MAIN
: init ()
: files (filesl, "main") → nbfiles
: clrscr ()
: map (vv, 0, nbfiles-1,1, printf1 ("% s", filesl [vv]))
: keywait ()
: free (filesl)
Example 2: See 'seqs ()' function
Function: reps (dest_direct_var)
This function allocates a memory space whose pointer will be saved in the variable
dest_direct_var and save in this space all the directory names present in the
calculator. Assigns the type of dest_direct_var to 10 (see typings), as well as the names of directories
are spaced 10 bytes apart in memory. The notation [] can then be used. This function
returns the number of directory names retrieved. The number of directory names returned
is limited to 50. This function returns 0 if the memory space runs out.
Example: See 'seqs ()' function

Page 64
NEWPROG2 & NPPTOC
8-Interrupts / timers functions
Function: inter ( interupt_ID, tick, {instruction1, instruction2,…} )
or inter ( interupt_ID, tick, x ) : instruction1, instruction2, ...: y
This function allows you to assign and unassign interrupts. An interruption is a
sequence of instructions which, according to user-defined parameters, will be executed
automatically at regular time deviation. Interruptions are a kind of way of doing
background tasks. Newprog allows you to define up to 20 interrupts, each identified by
an interrupt_ID between 1 and 21. The time difference between each execution of the
same instruction sequence equals: tick / 18 seconds. If two different interruptions occur
trigger at the same time, the one with the lowest identifier will be executed first.
The two syntaxes above are similar except that the second syntax allows the use of
commands other than functions such as 'if then else endif' tests for example. She permits
also to have a clearer program because it allows you to return to the line. Do not use in
instructions 'finish ()' functions in an interrupt sequence because the result is unpredictable.
Ensure that the execution time of all consecutive interrupt sequences does not exceed
not a certain one, otherwise the next wave of interruption will not conflict with the
previous. To temporarily stop the execution of an interrupt, call the function with
tick having a zero value (the third argument is useless in this case, so it can
simply be set to 0). To reactivate it, call the function with tick other than 0 and with the
third argument being literally "0". To stop all interruptions in one
instruction, call the function with a null identifier (the other arguments are useless in
case, we can then set them to 0 for example).
Since Newprog 2.0, it is forbidden to use local variables inside instructions
instruction1, instruction2 ... In addition, it should also be noted that an interupt_ID cannot
be associated with only one sequence of instructions; thus the redefinition of its sequence
instructions is now prohibited.
Example: Displays an incremented value at variable speed using an interrupt. The
program is automatically terminated after 30 seconds by another interruption.
: init ()
: clrscr ()
: prints ("Second: stop counting"): nl ()
: prints ("Diamond: Continue"): nl ()
: prints ("Left: decrease tick"): nl ()
: prints ("Right: increase tick"): nl ()
: prints ("ESC to exit"): nl ()
: nl ()
: prints ("Will close in real 30s")

Page 65
NEWPROG2 & NPPTOC
: 0 → time
// Initialize the variable value
: 18 → spleen
// Initially, the variable value is incremented every second
: 0 → reached
// End of execution variable after 30 seconds
: printxy (0,92, "Tick =% ld", rate) // Displays the Tick which can be modified by the left and right keys
: inter (1, rate, {printxy (10,70, "Moving value:% ld", isz (time))}) // Print the variable value
: inter (2, onesec * 30, x)
// After 30 seconds, exit the program automatically (onesec = 18)
: 1 → reached
: y
: While sto (kk, gkey ())! = 264 and not reached
: if second () Then
: inter (1,0,0)
// Pause the display of the variable value
: EndIf
: if diamond () Then
: inter (1, rate, 0)
// Relaunch the display of the variable value
: EndIf
: if kk = leftt and rate> 1 Then
// Decrease the Tick increasing the refresh rate of the variable value
: printxy (0.92, "Tick =% ld", dsz (rate))
: inter (1, rate, 0)
: EndIf
: if kk = rightt Then
// Increments the Tick decreasing the refresh rate of the variable value
: printxy (0.92, "Tick =% ld", isz (rate))
: inter (1, rate, 0)
: EndIf
: EndWhile
: clrscr ()
: inter (0,0,0)
// Pause all the interrupts before quitting
: Pause "finished"
Function: settimer (timer_no, T)
Assigns a timer with the identifier timer_no, with an initial value equal to T. Once this
function executed, each time auto-int 5 is triggered, i.e. approximately 18 times per second,
the value of the timer will be decremented by 1. The 'timerval ()' function is used to retrieve the value of the
timer, while the 'timerexp ()' function allows you to know if the value has reached 0. The identifiers
timers range from 1 to 6 on all available AMS. This function shares the identifiers of the
operating system of the TI89 and this is why it will be necessary to select wisely which
username to use. Certainly, identifiers 1 and 6 are free to use, so they are
privilege. Timer 4 is used for blinking the cursor, timer 2 for switching off
automatic calculator, timer 5 for the function delay. Cyclepic. It therefore remains free
identifiers 1,3 and 6. 'settimer ()' will return 0 if the timer is already in use or if it exceeds the number
maximum usable timers. The example below allows you to modify the delay before switching off
automatic calculator.

Page 66
NEWPROG2 & NPPTOC
Example: The calculator will turn off after 5 seconds. Then change this time to 100 seconds
: init ()
: settimer (5 * 18)
: text "Will turn off in 5 sec"
: settimer (100 * 18)
Function: freet (timer_no)
Releases an active timer with the identifier timer_no. Returns 0 on error, 1 also-no.
Function: timerexp (timer_no)
Determines whether or not the timer with the identifier timer_no has expired (see 'settimer ()' function).
Returns 1 if it has expired, 0 otherwise. Calling this function will reset the expiration flag
of the timer, the value returned on the next immediate call will therefore be 0.
Example: Wait 5 seconds before displaying "Timer expired"
: init ()
: settimer (1.5 * 18)
: nl (): prints ("Please wait")
: while not timerexp (1)
: printld (timerval (1)): nl ()
: endwhile
: freet (1)
: text "Timer expired"
Function: timerval (timer_no)
Returns the value of the timer identified by timer_no.
Example: See 'timerexp ()'

Page 67
NEWPROG2 & NPPTOC
9-Binary operations functions
Function: lrol (expr1, expr2)
Shifts to the left of expr2 bits on expr1. Expr2 must be positive. The new ones
bits (on the right) will be set to zero
C equivalent: expr1 << expr2
Function: rrol (expr1, expr2)
Shifts to the right of expr2 bits on expr1. Expr2 must be positive.
C equivalent: expr1 >> expr2
Function: notb (expr)
Performs a non-binary on the value expr and returns the result.
C equivalent: ~ expr
Function: andb (expr1, expr2)
Performs a binary and between expr1 and expr2 and returns the result.
C equivalent: expr1 & expr2
Function: orb (expr1, expr2)
Performs a binary or between expr1 and expr2 and returns the result.
C equivalent: expr1 | expr2
Function: xorb (expr1, expr2)
Performs a binary exclusive or between expr1 and expr2 and returns the result.

Page 68
NEWPROG2 & NPPTOC
C equivalent: expr1 ^ expr2
10-Arithmetic and logical operations functions
Functions: <> ≤ ≥ and or not + - * /
These are the same operators as in Tibasic.
Equivalent C:
<<
>>
≤ <=
≥> =
and
&&
gold
||
not
!
Function: isz (direct_var)
Increments the direct_var variable by 1. Returns the incremented value.
C equivalent: ++ direct_var
Function: dsz (direct_var)
Decrements the direct_var variable by 1. Returns the decremented value.
C equivalent: --direct_var
Function: unsigb (data)
Converts a signed 4-byte number (data) to an unsigned single-byte number. This
function finds its interest with the functions of reading ('lb ()' or []) of elements of lists (lists of
type 1 or 'b ()' is the equivalent of C char []) because these functions return signed numbers. This
function will allow for example to use lists of elements coded on one byte to store
abscissa of points to be drawn on the screen, without being limited to a maximum abscissa of 127 (being the

Page 69
NEWPROG2 & NPPTOC
maximum value of a positive signed number encoded on one byte). Indeed, the screen going on the abscissa
up to 159 pixels for a TI89 or 239 pixels for a TI92 or V200.
Example: Display the values ​​of a type 1 list (signed char) with or without 'unsigb ()'
init ()
: b (list)
: 1
: 100
: 200
: -1
: -100
: -200
: y
clrscr ()
: printld (list [0]): nl ()
// Displays 1
: printld (list [1]): nl ()
// Displays 100
: printld (list [2]): nl ()
// Displays -56
: printld (list [3]): nl ()
// Displays -1
: printld (list [4]): nl ()
// Displays -100
: printld (list [5]): nl ()
// Poster 56
: keywait ()
: clrscr ()
: printld (unsigb (list [0])): nl ()
// Displays 1
: printld (unsigb (list [1])): nl ()
// Displays 100
: printld (unsigb (list [2])): nl ()
// Displays 200
: printld (unsigb (list [3])): nl ()
// Displays 255
: printld (unsigb (list [4])): nl ()
// Displays 156
: printld (unsigb (list [5])): nl ()
// Poster 56
: keywait ()
Function: unsigw (data)
Converts a signed 4-byte number (data) to an unsigned double-byte number.
This function finds its interest with the functions of reading ('lw ()' or []) of elements of lists
(lists of type 2 or 'w ()' or the equivalent C int []) because these functions return signed numbers.

Page 70
NEWPROG2 & NPPTOC
11-Various functions
Function: rand (num)
Returns a random number between 0 and num-1
Function: off ()
Turn off the calculator.
Function: wait (delay)
Loops for delay hundredths of a second.
Function: catalog ()
Displays the catalog menu. Returns a string of the selection. This pointer will be valid until
next call to the function.
Function: debugon ()
Do not use with NPPTOC.
Enables debugging mode. The execution of the program will then be in step by step mode. The name of
the function will be displayed on the screen and thus may help to understand the error made.
Certain looping will not be executed in step by step mode (block x: y for example). It's forbidden
execute the 'debugon ()' function inside a function. To perform a function step by step,
it will be necessary to execute the function 'debugon ()' before executing it (in the main stream).
Function: debugoff ()
Do not use with NPPTOC.
Disable step-by-step execution (see 'debugon ()'). Returns to normal execution mode.
Function: nop ()
Do nothing.

Page 71
NEWPROG2 & NPPTOC
12-Library functions
For more details on the concept of libraries, see the corresponding section (“Libraries”).
Function: loadlib (lib_name_str)
Loads into memory the library whose name lib_name_str is in the form of a string of
characters. Returns a reference which will be useful later to perform its internal functions and
to close this library. If there is no memory, will display an error.
Function: exelib X (lib_ref, func_id [, arg1, ..., arg X ]) - X
ranging from 0 to 7
Execute the func_id number function of the library referenced by lib_ref ​​(see 'loadlib ()') and
if necessary returns a value. The value X corresponds to the number of arguments to pass to the
library function:
X = 0: No argument to pass to the internal function of the library. We then just have exelib0 (lib_ref, func_id).
X = 1: A single argument to pass to the internal function of the library. We then have exelib1 (lib_ref, func_id, arg1)
...
X = 7: Seven arguments to pass. We then have exelib7 (lib_ref, func_id, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
Function: closelib (lib_ref)
Close the library whose reference is lib_ref.

Page 72
NEWPROG2 & NPPTOC
E-Bookstores
1) Introduction
A library is a grouping of functions stored only in .ASM-.89z file (code
machine). They can be called from any Newprog executable program
(bytecode or machine code). It is possible to pass them up to 7 arguments.
They can be created from:
• Newprog source code directly on the calculator: specific instructions for
will differentiate from a classic Newprog code.
• pure C source code in the GCC4TI IDE: this solution makes it possible to use all the
functions / possibilities of C.
Libraries must be compiled in machine code in order to be able to be
used from a Newprog executable.
The user can also create his own libraries, from a suitable Newprog program or
from a C program also adapted. See below.
Note: The 'npplib2.ASM-89z' library is itself a Newprog library. Its use is
transparent to the user.
2) General: Loading - Function calls - Closing in a
Newprog program
There are three steps to using a Newprog library in a Newprog program
successive: loading it, using its functions and closing it.
• Loading:
To be able to call the functions of a Newprog library within a Newprog program, you
You must first have loaded it into memory using the 'loadlib ()' function.
Note: The upload will also internally prepare for the use of this
library by reserving a memory space containing among other things the values ​​of the arguments and the
pointers to referenced functions. The pointer of this memory space is returned by the function
'loadlib ()'.
• Call of a Newprog library function:
To execute a function, use the 'exelibX ()' function where 'X' goes from 0 to 7. 'X' corresponds to the
number of arguments passed to the library function (and not to the 'exelibX ()' function).
Note: Calling a library function is the C equivalent of calling a function
external via its pointer in memory.
• Closing :
The library is unloaded from memory (if archived) To close a library, use the function
'closelib ()'.

Page 73
NEWPROG2 & NPPTOC
Note: Also deallocates the memory space created during loading.
>> See the corresponding sections in the list of functions for details of their
uses. An example is given in the next section.
3) Creation of personalized libraries from Newprog code
The creation / definition of libraries from a Newprog code requires the use of words
keys / instructions. They allow :
• to inform the compiler that the Newprog code defines a library >> instruction 'aslib ()'
placed just after the initial 'init ()' command. This line is mandatory.
• to inform the compiler that one wishes to recover an argument for a library function
data >> instruction 'arg (X)' where 'X' is the number of the argument (1 to 7). If needed.
• inform the compiler that we are returning a value >> 'result (value)'. If needed.
• inform the compiler which functions will be accessible from the outside
>> 'libfuncs ({fa, fb, ...})' instruction. This declarative line is mandatory.
The index of the first declared function will be assigned to index 0, the second to index
1 and so on. To call an external function from a Newprog program,
we will pass the corresponding index in 'exelibX ()'.
• to test the functions accessible from
the outside >> instruction 'testfc ()'. This step is optional but recommended.
The machine code compilation of a Newprog library follows the same steps as for any other
Newprog program.
Example of definition of a Newprog user library:
: init ()
: aslib ()
// mandatory >> Indicates that we define a library
: "Next Year, i will be:" → str // Define a global string useful for this example
: def (fc0 (str1, str2))
// Define the internal function 'fc0 ()' which concatenates two strings
: settype (str1,1)
: settype (str2,1)
: rtn (str1 & str2)
: enddef (fc0 ())
: def (hello ())
// Define the external function 'hello ()'
: text fc0 ("Hello", "World!")
: enddef (hello ())

Page 74
NEWPROG2 & NPPTOC
: def (myage ())
// Define the external function 'myage ()'
: text "I'm" & string (arg (1)) & "years old." // get and use the argument of index 1
: result (str & string (arg (1) +1))
// idem and return a concatenation of strings
: enddef (myage ())
: libfuncs ({hello (), myage ()})
// Declaration of external functions: hello () and myage ()
: testfc (hello (), {})
// During the test, display "Hello World!"
: testfc (myage (), {20})
// During the test, display "I'm 20 years old.". Returns "Next Year, i will be: 21"
Once the library has been compiled in machine code and named for the example 'mylib', we can by
example use the library in a Newprog program as follows:
: init ()
: loadlib ("mylib") → lib
// Load the 'mylib' library. The reference is assigned in 'lib'
: exelib0 (lib, 0)
// Execute the external function of index 0 (no argument passing)
: text exelib1 (lib, 1,20)
// Execute the external function of index 1 (passing from the value 20 to the first argument)
: closelib (lib)
// Close the 'mylib' library
Will be displayed on the screen at runtime:
"Bonjour Monde !" then "I'm 20 years old." and "Next Year, i will be: 21"
4) Creation of personalized libraries from pure C code
The definition of a Newprog library in C is based on the model of the 'clibsrc.c' file found in
the Newprog 2.0 bundle. Its content is repeated below. A bookstore can also be created
on GTC oncalc than on GCC4TI on PC.
In all cases, the contributions of the programmer are confined in the area in bold as in
the example below, either between:
// WRITE YOUR OWN DATAS HERE BELOW //
and
// END OF YOUR DATAS //
The different sections to be completed are:
// WRITE YOUR OWN FUNCTIONS BODYS BELOW:
◦ Place here the body of your external functions (and possibly internal if necessary). The
return type of external functions must be void
func_name (void).
◦ If the user wishes to recover the value of an argument of index 'X' (going from 1 to 7),
use the 'ARGX' syntax. If the user wants an external function to return
a 'value' value, use the syntax 'RETURN value'. In these two cases, it will be necessary
obligatorily to place the sentence 'FC_HEADER' at the very beginning of the body of the function.
// ADD TO THE LIST HERE BELOW THE NAMES OF YOUR FUNCTIONS:

Page 75
NEWPROG2 & NPPTOC
◦ Declare here successively the external functions in the list named 'func ' . The
declaration position of an external function in this list corresponds to the number
index used in the call to 'exelib * ()'. The first element will have the index 0, the
second index 1 and so on.
// WRITE YOUR OWN INTERNAL DATAS BELOW:
◦ Declare here any internal data / buffers that can be used by
example in internal functions. See example below.
Example of definition in C of an external library:
#define MIN_AMS 200
// Compile for AMS 2.00 or higher
#define ARG1 data_ptr [0]
// retrieve first argument passed to the lib
#define ARG2 data_ptr [1]
// and so on
#define ARG3 data_ptr [2]
#define ARG4 data_ptr [3]
#define ARG5 data_ptr [4]
#define ARG6 data_ptr [5]
#define ARG7 data_ptr [6]
#define ARG8 data_ptr [7]
#define RETURN data_ptr [8] =
// for returning a value
#define ANSWER data_ptr [8]
// do not use
#define FC_LIST data_ptr [9]
// do not use
#define EXECHDL2 data_ptr [10] // do not use
#define COPYHDL2 data_ptr [11] // do not use
#define FC_HEADER long * data_ptr; data_ptr = * (long *) 0x5B04;
// put FC_HEADER statement at the beginning
of your LIB function if your if you use arguments ARG * or RETURN keywords.
#include <tigcclib.h>
// WRITE YOUR OWN DATAS HERE BELOW
// WRITE YOUR OWN INTERNAL DATAS BELOW
char * hello_str = "Hello World!";
// Character string (string) which will be used internally
// WRITE YOUR OWN FUNCTIONS BODYS BELOW
long add (long a1, long a2)
// internal function used in add_fc ()
{
return a1 + a2;
}
void add_fc (void)
// external function
{

Page 76
NEWPROG2 & NPPTOC
FC_HEADER // mandatory if we read the arguments passed to the function or if we return a value
clrscr ();
printf ("\ nARG1 + ARG2 =% ld", add (ARG1, ARG2));
// display the sum
ngetchx ();
RETURN ARG1 + ARG2;
// returns the sum of argument 1 and argument 2
}
void hello_fc (void)
// external function
{
clrscr ();
printf ("% s", hello_str);
ngetchx ();
}
// ADD TO THE LIST HERE BELOW THE NAMES OF YOUR FUNCTIONS
void (* func []) (void) = {add_fc, hello_fc}; // Definition of the external functions, indices 0 and 1
// END OF YOUR DATAS //
// Main () function, use as such
void _main (void)
{
unsigned int ii;
long * data_ptr;
if (* (long *) 0x5B04! = 123456)
{
clrscr ();
printf ("\ nNot intended to be launched!");
ngetchx ();
return;
}
data_ptr = malloc (12 * 4);
if (data_ptr == 0)
{
printf ("\ nNot enough memory when launching LIB.");
ngetchx ();
* (long *) 0x5B04 = 0;
return;
}
FC_LIST = func;
* (long *) 0x5B04 = data_ptr;
}

Page 77
NEWPROG2 & NPPTOC
Once the library has been compiled in machine code and named for the example 'mylib', we can by
example use the library in a Newprog program as follows:
: init ()
: loadlib ("mylib") → lib
// Load the 'mylib' library. The reference is assigned in 'lib'
: text "Sum =" & string (exelib2 (lib, 0,10,2)) // Execute the external function of index 0 (argument1 = 10, argument2 = 2)
: exelib0 (lib, 1)
// Execute the external function of index 1 (no argument passing)
: closelib (lib)
// Close the 'mylib' library
Will be displayed on the screen at runtime:
"ARG1 + ARG2 = 12" then "Sum = 12" then "Hello World!".
F-Warning / error reports to the
compilation
• Newprog compilation in bytecode:
When a compilation error is detected, the compiler returns an output file (npout)
describing the error and giving clues as to its location in the program (last function
and processed variable). When an error is detected during the execution of a program, it is
recommended to reset the calculator (reset) in order to solve the problems of memory leaks.
Warning: In order not to lose personal data, be sure to archive all your data
important before resetting the calculator (reset by pressing simultaneously on
2nd, left, right and on).
• Translation into C language with NPPTOC:
An error may appear during the translation into C language. The most common errors are
those relating to functions prohibited with NPPTOC (but not in bytecode) and those relating to
typing of variables.
• Compilation in machine code:
With GTC oncalc, if a warning appears, you can still continue the
compilation by pressing ENTER. This is of no consequence.
With any type of compiler, if an error appears during compilation (in rare cases), it is
a problem converting to C language. If you have a good knowledge of C, you
may be able to locate and correct the error.

Page 78
NEWPROG2 & NPPTOC
G-Predefined constants
When editing a program in the program editor, in order to facilitate programming, it
it is possible to use predefined constants. Type the name of a predefined constant in your
source code and then it will be replaced directly by its value during compilation. You do not
cannot use a variable corresponding to the name of a predefined constant because there would be
ambiguity.
Listing of predefined constants:
“False”
0
“True”
1
"lcdsize" 3840
"strtag" 0h2D
"listtag" 0hD9
"texttag" 0hE0
"asmtag" 0hF3
0hDC "functag"
"posexpr" 0h1F
"negexpr" 0h20
"exprtag" 0
"othtag" 0hF8
“Pictag” 0hDF
“Onesec” 18
“Gor”
0
“Greplace” 1
“Gxor”
2
“Greverse” 1
“Ghent”
3
“Gerase” 1
TI89 only:
"up"
337
"down" 340
"rightt" 344
"leftt"
338
"shiftt" 8192
"second" 4096
"diamond" 16384
"alpha" 32768
“Esc”
264
TI92 / V200 only:
"up2"
338
"down2" 344
"rightt2" 340
"leftt2" 337
"shiftt2" 16384
"second2"
4096
"diamond2" 8192
"alpha2" 32768
Example: Exit the program if the up and 2 nd keys are pressed simultaneously
: init ()
: clrscr ()
: prints (“press up + second to exit”)
: while gkey ()! = up + second
: endwhile

Page 79
NEWPROG2 & NPPTOC
H-Acknowledgments
I would like to thank everyone who contributed to the creation of GCC4TI and GTC. I thank
also TICT for their formidable graphic library EXTGRAPH.

Page 80
NEWPROG2 & NPPTOC
Appendix 1 - Internal structures of files
currents on TI68k
This appendix describes (in English) the internal structure of the various types of most used files.
on TI68k. You can check this information yourself using the hexadecimal editor
supplied with the bundle (mtihex.89z). To create files, the memory functions are very useful
(and particularly the 'fcreate ()' function).
TEXT files example
Ti89 text editor
Hexadecimal editor
From the byte of the lower address to the file to the upper address:
1) Size of the file: for this example 0h003B (16) = 59 (10) (in reality, the real size of the file, like you can see in the TI Var-link, is
0h00003B + 0h2 = 59 + 2 = 61 bytes)
2) Bookmark position: for this example 0h0003 = 3
3) Line struct:
3-1) first byte of the line struct corresponds to the command (F2):
20 = no command
0h0c = page break
0h50 = Print Obj
0h43 = command
3-2) Line content (can have no byte for an empty line)
3-3) Endline tag = 0h0D = 13 or = 0 for the last line
4) File type: TEXT Tag = 0hE0 = 224. (its address is equal to first byte address of the file + size of the file (here 59) +1)
OTH files example
From the byte of the lower address to the file to the upper address:
1) Size of the file: for this example 0h0025 (16) = 37 (10) (in reality, the real size of the file, like you can see in the TI Var-link, is 37 + 2 =
39 bytes)
2) Data bytes (put what you want)
3)
Optional sequence: Specify a personalize type for the file:
·
0h00
·
Name of the type. For example {N, P, P}
·
0h00
4) File type: OTH_TAG = 0hF8 = 248 (its address is equal to first byte address of the file + size of the file (here 37) +1)
ASM files example
Similar to OTH files but with file type = ASM_TAG = 0hF3 = 243.
FUNC and PRGM files example
For this file type, when editing the file (ff () for example) with an hexadecimal editor, we can have two type of output:

Page 81
TI89 Func editor (example for a function called ff (), replace Func and Endfunc by Prgm and Endpgrm for a program) hexadecimal editor:
Output1 (before TI os compilation (or before launching the func if you have just before edited the function in
the function editor)
hexadecimal editor: Output2 (after TI os compilation (ie file execution)
Output 1 struct (before compilation)
From the byte of the lower address to the file to the upper address:
1) Size of the file: for this example 0h003A (16) = 58 (10) (in reality, the real size of the file, like you can see in the TI Var-link, is 58 + 2 =
60 bytes)
2) Line struct:
2-1) Line content (can have no byte for an empty line)
2-2) Endline tag = 0h0D = 13 or = 0 for the last line
3) Ending sequence:
3-1) Bookmark position on two bytes, on the example = 0h0003
3-2) Byte = 0h17, you must enter this value if you want to have a FUNC type (it also a mean to differanciate FUNC type files ans PRGM
types files, see further below). If you want to have a PRGM file type, you will have to enter 0h19 instead of 0h17.
3,3) Four bytes = {0hE4, 0hE5, oh00, 0h00, 0h08} (don't know why this values)
4) File type: FUNC Tag = 0hDC = 220 (for both FUNC and PRGM file type). (Its address is equal to first byte address of the file + size of the file
(here 58) +1)
Output 2 struct (after compilation (ie after running))
From the byte of the lower address to the file to the upper address:
1) Size of the file: for this example 0h0036 (16) = 54 (10) (in reality, the real size of the file, like you can see in the TI Var-link, is 54 + 2 =
56 bytes)
2) Func codebyte (will not be explained by me because very complicated)
3) File type: FUNC Tag = 0hDC = 220. (its address is equal to first byte address of the file + size of the file (here 54) +1)
EXPR files example
case 1: The var x contained a number (here, x = 9)
For the variable x = 9.
Hexadecimal editor

Page 82
case 2: The var x contained a var name (here azerty)
For the variable x = azerty.
Hexadecimal editor
For this data type, if you want to read the value contained in this file, you have to read from the last byte of the file (the one who have the
higher address to the one with the lower address) to the lower address of the file.
To determine the position of the last byte, you will have to addition the first byte address of the file with the size of the file -1.
The size of the file is equal to the content of the first two bytes coded value of the file, in this example +2. For this example, the size of the
file is size = 0h00003 + 2 = 5 bytes length.
Knowing the size of the file, you can calculate the address of the last byte:
last_byte_adress = first byte address of the file + size - 1.
So, going from the last byte to the first byte:
1)
Last_byte: corresponding to the value_type of the data stored in the file (it will always be shown with “EXPR” tag in the ti-
varlink and in Newprog too (with the gettype () function).
The value_type can have this values:
0h1F: positive data value (case 1)
0h20: negative data value (case 1)
0h00: variable (in symbolic form) (for example, when: azerty-> x) (case 2)
2) DATA sequence (always going from the last byte to the first byte):
2-1) In case of positive data value or negative data value (case 1)):
- first following byte: number of byte data length (here 1 because 9 is <255 so can be coded on only one byte)
- following bytes (their number is stored in the previous byte) for the data value storing. (in big endian if you read from the lower address to
the upper address or in little endian when reading from the highest address to the lower address).
2-2) If the variable doesn't contained a value but a var name (case 2), the data sequence contains the name of the variable.
3) The last two bytes contained the size of the file -2 (in the same way than other files).
LIST file example
A list contained a multiple of EXPR.
1)
The first two bytes content is equal to the size of the file -2.
2)
0hE5 = endtag (specify the end of the list)
3)
Put EXPR; STRING or LIST sequences (In the same way than in this document, but wihout the two byte of the size.
4)
The last byte of the file is equal to 0hD9 = 217.
For reading one by one each values ​​contained in the list, you have to go from the end of the file to the beginning of the file. After the last
byte (which is localized at the first byte address + size - 1) you will have the tag of an EXPR data type. To read this value, see the
EXPR data sequence written above. Just after this data sequence, you will have the tag of the second EXPR data type. So, by this
way, you can fetch each value contained in the value one by one by going going through the file. The end of the list is indicated by
the tag 0hE5.

Page 83
STR file example
1) First two bytes = size of the file - 2 (size of the file must be equal to the size you will see in the varlink)
2) 0h00
3) Put your string with the end null character
4) STR_TAG = 0h2D
MATRIX file example
A matrix is ​​a list of LIST. Here below an example:
PIC file example
1)
The first two bytes content is equal to the size of the file -2.
2)
The next two bytes contained the number of rows (for instance = 0h0009 for a pic containing 9 lines)
3)
The next two bytes contained the number of columns in pixels
4)
Bitmap sequence. For a all black picture of 8 rows x 8 columns, we will have: 0hFFFFFFFFFFFFFFFF
5)
Pic tag = 0hDF

Page 84
Annex 2 - Version history
2021: Newprog Release 2.0 - Improvements since release V1.0
Rewriting of the documentation (more detailed, clearer, more precise, corrections of spelling mistakes)
Addition of the concept of libraries
Added machine language compilation mode (NPPTOC)
Numerous bug fixes.
Addition of functions:
loadlib ()
exelibX ()
closelib ()
wait ()
Changes to functions:
seqb_w_l_e_s (): New syntax: seqb_w_l (dest_var_ptr, moving_var, start, end, step, expr).
seqe_s (): New syntax: seqe_s (basic_dest_var_str, moving_var, start, end, step, expr).
Files: New syntax files (dest_var, rep_str)
inter ()
Removal of unnecessary functions:
loadasm ()
execasm ()
closeasm ()
multi()
two ()
Basich ()
execbas ()
freeh ()
pos ()
gotopos ()
jsr ()
rts ()
Number of user functions limited to 30 in the body of a program.
03/2010: Newprog Release 1.0 - Improvements since release V0,1
Now Newprog assumes that the first instructions in the program are Newprog instructions (instead of release 0,1).
Keys words end and start have been renamed by basic and endbasic .
A memory leak in qbasic has been corrected.
Now, qbasic verify whether the file passed is really a NPP file => Crash corrected.
Now, if an error occured in a Tibasic instruction, the program will not been stopped by an error displaying (nothing will happen).
In clrlcd (): Great speed impovement of about 17 time faster (now 6500 calls / sec)
In clrscr (): Great speed impovement of about 24 time faster (now 6000 calls / sec)
In savescr: Great speed improvement of about 5 time faster.
In loadscr: Great speed improvment of about 5 time faster.
In dline: Great speed improvement (up to 10 times faster)
In fillrect: Great speed improvement (16 time faster than previous routine).
In sprt8, sprt16, sprt32: Speed ​​increased of about 71%. Now worked as clipped (ie will not crash if coordinates are out of [0,0,239,127]).
In dpix: Great speed improvement.
In gpix: Speed ​​increased of about 30%.
In memcopy: Execution speed is about 6.5 time faster for a an amount of bytes to copy at least equals to 384 bytes.
In while: endwhile: speed increased of about 30%
In Tibasic sequence: A bug has been corrected when size of the sequence was> 255 bytes.
In def, enddef, fc: A bug has been corrected when at least 30 variables was defined.
In jsr: A bug has been corrected when at least 30 variables was defined.
In rts: A bug has been corrected when launch without previous jsr ().
ifs () renamed by when ().
chars () renamed by char (). The return value is now available in memory up to the next call of this function (you don't have to free the return
value before the end of the program).
code () renamed by ord ().
int1off () renamed by keyclear ().
int1on () renamed by keydisp ().

Page 85
fopen (), great modifications: The function is totaly modified.
or, and and not functions work now has logic test and not test on binary operations (see new functions orb (), andb (), notb () for binary
operations).
While: Endwhile: a bug has been corrected (when two endwhile were closed).
gmode: graphic mode value has been change for real compatibility between all graphics functions.
keywait (): a bug is corrected (when using with keyclear () (previous name of keyclear: int1off ()).
New Functions:
= for strings comparison (simplify to use than strcmp ()). Return 1 if equal, else 0.
andl: binary and operation (former and operator in newprog release v0.1).
orl: binary or operation (former or operator in newprog release v0.1).
sprt82: display a sprite even if in the border of the screen.
sprt162: display a sprite even if in the border of the screen.
sprt322: display a sprite even if in the border of the screen.
newline or nl: Return to a new line (with the printf1 ... functions).
when: replaced the ifs functions in release 0.1
i: is a simple writing for if endif function (with no else for the moment). As fast as an if endif statement. Use the following syntax:
i (condition): instructions: y
catalog: Launch the catalog dialog and return a string of the
selection. For: Endfor
open: display an open dialog box. The user select the folder and the file (and can choose the type). Returns a string: "rep \ varname"
mod: modulo function. Example: mod (9,7) returns 2.
atol: convert a string to number (like expr in tibasic)
&: similar to tibasic. The output shall be smaller than 50 bytes for avoiding crash. If the size is bigger than 50 bytes, use strcat () instead.
lcdup: contrast up.
lcddown: constrast down.
b, w, l: 3 functions to define predifined instantiated list.
prettyxy: display an expression into pretty print format (very impressive).
getwbt: retrieve the dimension of the expression to be displayed with prettyxy.
settype: set the type of data (ie their size) contained in a list pointed by a Newprog variable. Returns the old value. The function could just
returns the old value without modifying it.moveto: Sets the current pen position.
pause: Display a string to the screen and wait for a key to be pressed
seqs: Great function for making Tibasic list filled with strings
seqe: Great function for making Tibasic list filled with expressions (ie number only)
orb: binary or
andb: binary and
notb: binary not
fopen (file_str): open an existing file for reading and modificating. If you want to save your modifications, you have to use the fcreate
function.
fcreate (file_str, string_type): create a file or overwrite a file
next: returns to the beginning of the last opened and active For or While loop.
break: Ends the last opened For or While loop.
esc: acts like up () down () etc but for escape key.
off: turns off the calculator
isarchi: Return 1 if file is archived, 0 if not, -1 if doesn't exist.
archi: archive a file.
unarchi: unarchi a file.
gsprt8x: retrieve from the screen a sprite with custom bytewidth.
sprt8x: Display to the screen the sprite (in particular from gsprt8x).
dcircle: Draw an outlined circle.
fillcirc: Draw a filled clipped circle.
memchr: Search for a character in a memory area.
text: Same function than the Tibasic one.
unsigb: converts a number coded onto 4 bytes (data) on a signed number coded onto one byte
unsigw: converts a number coded onto 4 bytes (data) on a signed number coded onto two bytes
osvar: Return the value of a Tibasic variable
if: if cond: if_true
ord: converts a string of one character to a code ascii
New: Predefined constants (operating during compilation)
Functions removed because do not work correctly: fputc (); ftell (); fseek (); fputs (); fclose (); interoff (); interon (); int5off (); int5on () etc few others
one is.
Program stability enhanced (by verifying whether the function executed is still in the programm memory area (C exec_non_stop_secured ()
function)).
Program stability enhanced when executing Tibasic.
Memory leak corrected.
In jsr, bug corrected when to many jsr called (memory problem).
In the compilator point of view:

Page 86
The first intruction of the program is assumed to be a Newprog instruction and not a Tibasic one like it was the case in the previous release.
An error about the compilation of the writing [] has been deleted. Now the list [1, prints ("Crazy")] will be executed as list [x]: prints ("crazy").
The compilator compares if the number of functions allocating memory is equal to the amount of free () function detected. If amounts not
equal, the compilator displays a warning.
The compilator now displays a warning if the number of arguments passed to the program is wrong.
The compilator not crash if an unknown Tibasic command is used.
We can now put variables and predefined constants in the definition of a dynamically instantiated list. Example: {varn, 4,1,7, title, 4, strtag}
New instantiated list: b, w and l.
Can now launch a function with the () notation (with possibility to pass locals variables)
Bug corrected in the error output. The last foncname and var name and line number (where the error occured) are now correctly displayed.
Some errors message written in french have been rewritten in english.
If a variable is alone, a warning will be displayed.
if: if cond: if_true notation (Like in Tibasic)
Add: false (value = 0) and true (value = 1).
Predifined routine constants defined.
@ rating for comments
Speed ​​optimizations:
Now, if you write ord ("a"), it will be written internally 97. And so on ...
06/2009: Newprog Release 0.1 (beta version):
Mains Newprog features defined.

Texte d'origine