PETOOLS 1.0 - Reference

PETOOLS 1.0 is a set of machine language routines, which extends the possibilities of your sharp in graphics, sound and other functions. It comes with a  GPL and without waranty of any kind.

API Documentation

CAL2M

Read the CAL-mode memory and store it into standard variable M. This is done by a CALL 32820.

M2CAL

Read the standard variable M and store it into the CAL-mode memory. This is done by a CALL 32839. Caution: If the content of M is a string (if M$ was used), the behavior of this routine is not defined.

FLASH

Flashes the display. Using CALL 32862 will flash the display with the default number of times (11 times). Using POKE 32859,n:CALL 32858 will flash the display n+1 times.

GCURSOR

Poke the graphics cursor position to address 32964, e.g. POKE 32964,10 will set the graphics cursor to column 10 (first column of the third character field). The graphics cursor position is used by the GPRINT command, the valid range is [0 .. 119].

POINT

Returns the bitmap of the specified display location (column). Poke the column number to address 32972 (valid range is [0 .. 119]), then perform a CALL 32971. PEEK 32965 returns the bitmap of the column.

RENEW

In case of an accidental NEW-command just type CALL 33000, and you will get your programs back. If you want to undo a ALL RESET, you have to do some precautions before the ALL RESET-button is pressed. Type PEEK &FF01 and PEEK &FF02 and write the resulting numbers at the inside of your sliding top - so you will have them always handy (When using PETOOLS 1.0 the values should be 157 and 131 on a 1403H or 157 and 227 on a 1403). In case of an accidental ALL RESET just type

POKE &FF01,Value1,Value2
CALL 33000

and you will get your programs back.

GPRINT

Hints (for all GPRINT-calls):

Single Column

Poke the desired pattern to address 33037, then perform a CALL 33036. This will draw the pattern to the current graphics cursor position. The graphics curser position will be increased after that.

Standard Variable (String, max. three Columns)

First, poke the number of the standard variable you want to use ("A$" is 1, "B$" is 2, and so on ...) to address 33081, e.g.

POKE 33081,26:REM Use Z$

will use the standard variable "Z$" for the following GPRINT-call. Then, assign a string constant containing the hexadecimal values for the pattern to display, e.g.

 Z$="7F417F"

The GPRINT-call is done with

CALL 33078

Note: GPRINT with standard variables is faster than using single columns. If you're using a numeric variable, the result (the displayed pattern) will be undefined.

Field Variable (String, max. 40 Columns)

To use this function, you must know the address of the field variable first. This can be done like shown in the following code example:

BA=0:DIM BS$(0)*10
BA=256*PEEK 65288+PEEK 65287

The first line fixes the dimension of the field variable. The second line determines the address of the field variable and stores it into BA. Why is BA set to zero in the first line? If you would not do this and the variable BA would be used the first time at this point, then the memory for the variable would be allocated here and this would make the result of the peeks incorrect. After determining the address of the field variable assign a string constant containing the hexadecimal values for the pattern to display, e.g.

BS$(0)="1C3E3E3614"

After this, set the address of the field for the following GPRINT-call:

POKE 33105,BA-INT(BA/256)*256,INT(BA/256)

The GPRINT-call is done with

CALL 33107

Note: GPRINT with field variables is the fastest graphics output routine, because you can draw max. 40 columns with one call.

GMODE

Switches the bitblt mode. There are four call addresses: The graphics cursor position (GCURSOR) is set to zero, also the fill pattern used by GFILL and GPRINT (Single Column). The fill range is set to the full range (From 0 to 120). Warning: There is no default for GMODE (e.g. on calling RUN or CLEAR), so it's always a god idea to call GMODE once at the start of a program.

GFILL

Fills a range with a given pattern using the current bitblt mode. There are four addresses: The graphics cursor position is set to the end of the range after execution. Example:

POKE 32965,&41,30,100:CALL 33330

This draws two lines from the 6. character position to the 20. character position (not included). GFILL is very powerful, you can fill, erase or invert the screen or parts of it or you can draw rectangles very fast.

SCROLLCLEAR

Clears the display by scrolling it up or down. There are four call addresses:

BEEP

Creates a beep with variable duration and frequency. Example:

10 POKE 33448,INT A-256*INT (A/256),(A/256)
20 POKE 33450,B
30 CALL 33452

The variable A varies the frequency, the valid range is [0..1019]. The variable B varies the duration, the valid range of it is [0..255]. You can use the following equation to calculate the frequency:

f = fClock / (A + 51)    [Hz]

The clock frequency of my 1403H is 249900 Hz with batteries of medium quality. The maximum frequency (A = 0) with this clock frequency is 4900 Hz, the minimum frequency (A = 1019) is 234 Hz. To convert programs from a 1500 use the following equation:

A1403 = INT (A1500 * 4.437138 - 19.81)

Caution: The full frequency range of the 1500 isn't covered by this command (Valid range: [5 .. 234], this are more than 4 octaves).

The duration is

d = B * = 0.002    [s]

Note that the duration gets a little bit inaccurate when using low frequencies. This is because the inner loop of the ML algorithm last longer than a timer tick (2 ms).

Example:

10 POKE 33448,3,200,8:CALL 33452:POKE 33448,0,200,4:CALL 33452

Gives a nice little BEEP, which isn't so annoying as the original BASIC BEEP.

BEEP ON/OFF

The beep routine can be turned to silent mode (same duration, no sound output) by using CALL 33672. You can turn the sound output on by using CALL 33662. Warning: There is no default for BEEP ON/OFF (e.g. on calling RUN or CLEAR), so it's always a god idea to turn BEEP ON or OFF once at the start of a program.

APPENDIX

MEMORY EXTENSION

The PETOOLS 1.00 are located in the basic memory starting at 32816. It uses 877 bytes. The next free address is 33693.

BUILDING PETOOLS 1.0

You can download all mentioned files here:  petools1_0.zip.

Edgar Pühringer last modified: 14.2.2001