home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
aminet
/
easylife.lha
/
EasyLife.doc
next >
Wrap
Text File
|
1993-10-19
|
43KB
|
1,309 lines
************************************************************************
** **
** EASY LIFE Extension V1.0 **
** ------------------------ **
** **
** Written By Paul Hickman ©August 1993 - named after EASY LIFE **
** from Steve Wright In The Afternoon **
** **
************************************************************************
Send Bugs / Ideas / YOUR PROGRAMS to ph@doc.ic.ac.uk
Contents
--------
0.0...........How To Lead An EASY LIFE
0.1.........Zone / Multi Zone Commands
0.2....................String Commands
0.3................Powerpacker Support
0.4..............Bit test/set Commands
0.5.....................I / O Commands
0.6......................Misc Commands
0.7......................The Workbench
Section 0.0 - How To Lead An EASY LIFE
--------------------------------------
The EASY LIFE extension is designed to do just that - make life
easier - especially the parts of said life spent writing AMOS
programs. The commands included are not designed to speed up
graphics to amazing levels, even on an bog standard A500 which has
had the MC68000 pulled out, and replaced with a lego brick, or to
put a starfield in the background (Why is it virtually evrey
extension written has starfied commands???), but to speed up the
actual computing work done in the background, and to allow you to
read various internal AMOS variables.
The EASY LIFE garuntee
----------------------
EASY LIFE is garunteed to:
a) Not necessarily to what this file says it will
b) Not necessarily do anything
c) Not necessarily load
d) Contain at least 20 spelling mistkes in this file
e) Really get on your nerves, and not really make your life very
easy at all, if some command decides it's not going to act
the way it's supposed to an goes and invalidates your hardisk
f) Not to do any washing up
I do not accept responsibilty if any of these events occur (except
the last one - If you find a way to E-Mail washing up to me, I'll
do it), or if anything else goes wrong (Or right!)
How To Get An EASY LIFE
-----------------------
Copy EasyLife.Lib into the AMOS_System Drawer of your AMOS
boot-disk. Copy powerpacker.library into the Libs drawer. (Or the
AMOS_System & Libs drawers of you harddisk)
Then load AMOS, then load the AMOS1.3_Config program, then Run it,
then load the default configuration, then go and find a theasarus
(try looking in Jurasic Park), and look up an alternative to the
word "then". NEXT select "Loaded Extensions" from the menu, and
click on the Extension no 16 line, and type
:AMOS_System/EasyLife.Lib
Then (Here We Go Again) press the quit button, then select save
default configuration, the Quit to System, and finally load AMOS
again. (Or if using a floppy, just reboot after saving)
Making Someone Else's Life Easier
---------------------------------
EasyLife V1.0 is freeware - feel free to distribute it to anyone,
and use it in your programs. All I ask is that you mention my name
in the doc file of any programs you distribute that use EasyLife,
and that you distribute all the files in this archive together.
EasyLife Upgrades
-----------------
If you would like to know when an upgrade to easy life is available
E-Mail me (ph@doc.ic.ac.uk) and I'll add your name to the list.
General Notes
-------------
In addition to the list of possible errors from each command, Out
of memory errors / Variable buffer full may also occur.
NOTE: Errn returns 4096+Error number when easylife produces an
error
NOTE: The El Error value is cleared to -1 when it is read. This
means that if other extensions produce an error, El Error will not
contain the number of an EasyLife error you've already handled.
Section 1.0 - Zone Support Commands
===================================
1.1 Finding Zone Co-ordinates
-----------------------------
=Znsx( ZONE )
=Znsy( ZONE )
=Znex( ZONE )
=Zney( ZONE )
These commands will return the co-orinates of the chosen zone, of
of current screen. E.g.
After the command: Set Zone 1,10,20 To 30,40
Znsx(1) will return 10, Znsy(1)=20, Znex(1)=30, and Zney(1)=40
NOTE: These commands return signed integers. (-32768 to 32767)
Errors
------
If the zone number given has not been reserved an illegal function
call is generated.
If no screen is opened, a "Screen Not Opened" error is returned
Alternative Format
------------------
=Znsx( SCREEN, ZONE)
=Znsy( SCREEN, ZONE)
=Znex( SCREEN, ZONE)
=Zney( SCREEN, ZONE)
These commands will return the co-ordinates of the given zone, on
the chosen screen
Errors
------
As above, and if the given screen is not opened, a screen not
opened error occurs.
1.2 Scrolling Zones
-------------------
Zn Shift SCREEN,DX,DY
Zn Shift SCREEN,DX,DY,START To FINISH
The first instruction will scroll all the zones defined on the
given screen DX pixels to the right, and DY pixels downwards. To
scroll to the left, or upwards, make DX/DY negative.
The second variation will only affect those zones between START
and FINISH
Errors
------
If the given screen is not open, a Screen not opened error occurs.
An Illegal function call occurs under the following circumstances:
- No zones are reserved on the given screen
- START or FINSH is greater than the number of zones reserved
- START is greater than FINISH
NOTE: If you shift a zone below co-oridinate 0, no error occurs,
but 65536 is added to the new co-ordinate (modulo 65535 arithmatic)
1.3 Multi Zone Commands
-----------------------
What is a multi zone?
A multi zone is similar to a normal screen zone. It is a
rectangular area of the screen, and you can detect it given
co-ordinates fall within it. The diferences are:
- Multi zones are identified by a GROUP number, and a ZONE number.
Neither need be sequential, you can define zones 1,3,10 of group
1, then zone 431 of group 839 if you want - it will still only
take 4 zones worth of memory.
- Multi zones can be erased one group at a time
- You can detect if co=ordinates lie in any zones, or just zones
from one group
- You can detect ALL the zones a point lies in, not just the
first one in the list.
1.3.1 Reserving Space
---------------------
Reserve Multi Zone NUM
This command is the equivilent of the Reserve Zone command. It
reserves memory for the chosen number of zones. NUM must be even.
If the value you supply is not, it is rounded up. A maximum of
5460 multi zones can be defined.
The Multi zones take the place of the normal screen zones in the
screen data structure, so they cannot be used at the same time.
Multi zone commands will produce an error message if you attempt
to use them when normal screen zones are defined. Normal screen
zones will not work with multi zones installed, but will not
produce error messages, just unreliable results.
NOTE: When you call Reserve Multi Zone, the previously installed
zones/multi zones are erased - you do not get a Zones already
reserved error.
Errors
------
Out of memory No memory for the zone table.
1.3.2 Eraseing multi zones
--------------------------
Reserve zone
This the standard AMOS reserve zone command. Used with no
parameters, it will erase all multi zones. They are also erased
properly when the screen is closed / default command used.
1.3.3 Defining multi zones
--------------------------
Set Multi Zone GROUP,ID,X1,Y1 to X2,Y2
Set Multi Zone GROUP,ID
This is virtually identical to Set Zone command, except you must
supply a GROUP number. GROUP and ID can be any number between 1
and 65535. X1,Y1,X2,Y2 can be between -32768 and 32767.
X1,Y1 and X2,Y2 are automatically sorted so X1 <= X2, and Y1 <=
Y2, so Mznsx etc. always read the correct values.
The second form of the instruction erases the selected zone.
NOTE: If you call Set Multi Zone twice with the same GROUP & ID
numbers, the old co-ordinates are overwritten.
Errors
------
Illegal Funciton Call GROUP & ID cannot be 0
Zone table full You have not reserved enough
multi zones.
Multi Zones Not Reserved You have not reserved any multi
zones.
1.3.4 Reading multi zone co-ordinates
-------------------------------------
= Mznsx(GROUP,ID)
= Mznsy(GROUP,ID)
= Mznex(GROUP,ID)
= Mzney(GROUP,ID)
These are multi zone equvilents of the commands in section 1.1.
All operate on the current screen.
NOTE: Set Multi Zone sorts X1,X2,Y1,Y2 so mznsx/sy are always <=
mznex/ey.
NOTE: The values returned are signed. (-32768 to 32767)
Errors
------
Multi Zone Not Defined Zone GROUP,ID does not exist
Screen Not Opened
1.3.5 Detecting points in multi zones
-------------------------------------
= Mzone(X,Y)
Returns the ID of a multi zone set on the current screen that X,Y
lies in. The zone can be from any group.
= Mzone(X,Y,G)
Same as above, but only zones in group G are checked.
NOTE: These commands return 0 is no zone matches.
= Mzoneg
Returns the group number of the zone matched by either of the last
two commands (Although this is a bit pointless if you specify a
group to search!). 0 is returned if the last search failed.
= Mzonen
Searches for a another zone the contains the point defined in the
previous Mzone command. If you supplied a group, only zones in
that group are matched.
NOTE: These zones won't be returned in any particular order
1.3.6 Clearing a group
----------------------
Clear Multi Group G
Erases all zones in group G
1.4 Zone Editor "Zone Bank" Compatibility
-----------------------------------------
Zb Add SCREEN, BANK, GROUP
This command installs zones from a zone bank, created by the zone
editor program. SCREEN is the screen you wish to set the zones on.
BANK is the bank number containing the zones, and GROUP is the set
of zones within the bank you wish to install.
NOTE: This command clears all previous zones set on the screen.
Errors
------
Bank does not exist Obvious
Not a Zone Bank Bank name must be "Zones "
Illegal Function Call Group does not exist in the bank
Screen not opened Obvious
Out of memory 8 bytes per zone is required
Zb Multi Add BANK, GROUP
This command install all zones from the chosen group as multi
zones. Unlike the previous instruction, this does not erase the
current zones. This means that you will have to reserve enough
multi zones to contain the group first. The only zones overwriten
by the command are those with the same GROUP & ID numbers as those
in the bank.
Errors
------
Bank does not exist Obvious
Not a Zone Bank Bank name must be "Zones "
Illegal Function Call Group does not exist in the bank
Screen not opened You must have a current screen
Multi Zones Not Reserved No multi zones are reserved
Zone Table Full Not enough zones are free
Zb Install BK
This command installs all zones in all groups of bank BK as multi
zones. Firstly, it counts the number of zones in the bank, and
reserves this many multi-zones. Then it calls the prevoius command
on each group of the bank
NOTE: The zones are installed on the current screen.
Errors
------
Bank does not exist
Not a Zone Bank
Screen not opened Zones installed on current
Out of memory No memory to reserve multi zones
Section 2.0 - String Support
============================
2.1 Character Search Functions
------------------------------
=Find Asc(S$,A) =Find Char(S$,A)
=Find Asc(S$,A,P) =Find Char(S$,A,P)
=Find Not Asc(S$,A) =Find Not Char(S$,A)
=Find Not Asc(S$,A,P) =Find Not Char(S$,A$,P)
=Find Last Asc(S$,A) =Find Last Char(S$,A$)
=Find Last Asc(S$,A,P) =Find Last Char(S$,A$,P)
=Find Last Not Asc(S$,A) =Find Last Not Char(S$,A$)
=Find Last Not Asc(S$,A,P) =Find Last Not Char(S$,A$,P)
All sixteen of these commands search for a single character in the
string S$, returning it's position, or 0 if it was not found.
In the Asc variants, the parameter A is the AscII code of the
character to search for. In the Char variants, the first character
of the string A$ is used as the search character
Those containing the word NOT will match any character other than
the one given in A / A$. Those containing the word LAST begin the
search from the end of the string.
Find Asc/Find Char
------------------
These search from the begining of the string for the character. If
the optional parameter P is supplied, the search begins with
(P+1)th character of the string. Therefore to find the second
occurance of the character, call Find Asc/Char with the position
of the first occurance in P.
These commands are similar to the =instr command, but are faster
as they only match single characters, and instr will search from
position P, not P+1, if it is supplied.
Find Not Asc/Find Not Char
--------------------------
These behave exactly like the Find Asc/Find Char versions, but
search for any character that other than the one supplied in the
second parameter A/A$. This is usefull to skip spaces, just use
A$=Mid$(A$,Find Not Char(A$," "))
Find Not commands will return 0 if either the string s$ was empty,
or if s$ only contained the character that wasn't to be found.
Find Last Asc/Find Last Char
----------------------------
These variants search from the end of the string instead of the
start. This means the if the parameter P is supplied, the search
begins with the (P-1)th character.
Find Last Not Asc/Find Last Not Char
------------------------------------
These two search from the end of the string for any character
other than the one contained in A/A$. If P is supplied, the search
begins from the (P-1)th character
Errors
------
An illegal function call occurs in the following circumstances:
- The A$ parameter contained an empty string in any of the Char
versions
- The A parameter was greater than 255 or smaller than 0 in any of
the Asc versions
Note
----
These routines will take any value of P. The value is unsigned, so
any negative P is taken to be over 200 million!
If P is past the end of the string, Find & Find Not will return a
0. Find Last will just search from the end of the string.
2.2 Finding Control Characters
------------------------------
=Find Control(S$)
=Find Control(S$,P)
These special versions of the above commands find the first
occurance of a character with AscII below 32 in the string S$
(Starting at position P+1 if P is supplied). The position of the
first control character is returned, or 0 if the string contains
no control characters.
This can also be used to determine if a string is printable:
If Not Find Control(A$) Then Print A$ : Else Print "Unprintable"
2.3 Bank name strings
---------------------
When you use the ListBank command the first column of the table
gives you the type of the bank in an a 8 character string. Easy
Life gives you commands to read & change these names.
=Bank Name$(NO)
Returns an 8 character string containing the name of the bank.
Shorter names are padded with spaces. NO is the bank number to
return the name of.
Set Bank Name NO,NAME$
Sets the name of bank NO to NAME$ (Which must be an 8 character
string). This change is permanent, and is saved with the bank.
WARNING: Not all bank names should be changed, as some extensions
use them to check the bank type (In fact =message$ does this, so
don't change message banks), but it is useful with Sprites, Music,
Work, and Datas banks.
Errors
------
- A "Bank Does Not Exist" error occurs if Bank NO doesn't exist
- An illegal function call occurs if NO is not a legal bank number
- An illegal function call occurs if NAME$ is not 8 characters long
2.4 Strings & Memory
--------------------
=Mem$(START,LENGTH)
Returns a copy of the memory region from START to START+LENGTH in
a string.
NOTE: This is a copy of the memory area, put inside the AMOS
variable buffer, so if the memory area is later changed, the
string is not affected.
NOTE: The maximum length of a string is 65535 characters, so
length must not be greater than this
=Mem$(START,LENGTH,DELIMITER)
This will search the memory from START to START+LENGTH for a
character with AscII code DELIMITER. Then it will copy the memory
area between START, and the position of the delimiter into the
string which is returned.
NOTE: If the delimeter character is not found, the entire memory
segment from START to START+LENGTH is copied.
NOTE: The delimeter itself is not returned on the end of the string.
Errors
------
It is easy to get a variable buffer full!
An illegal function call occurs if:
- LENGTH is negative, or 0
- LENGTH is greater than 65535 on the Two parameter function call
- LENGTH is greater than 65535 on the Three paramter call, AND the
delimeter character is not in the first 65535 bytes of the
memory area
- The DELIMETER paramter is not between 0 and 255.
Mem START,S$
This command is the opposite of Mem$. It copies the string S$ into
memory begining at location START. If S$ is empty, nothing is done.
Errors
------
No errors are generated, but you can cause a guru or worse by
writing strings into memory at random.
2.5 Message Bank Support
------------------------
Easy Life make life much easier when you use the Message Bank
Compiler Integerated into my PratchED text editor. To get a
message, simply use the command:
=message$(BANK,GROUP,NO)
BANK is the number of bank containing the messages. GROUP and NO
specify which message from within the bank to return.
NOTE: A copy of the message is returned, and it can be edited
without affecting the original bank.
Messages can also be read from other areas of memory where you have
loaded a message bank - just replace the BANK parameter in this
command with the address of the message bank. For example to read
messages from a powerpacker buffer (See Section 3), use:
=Message$(Pp Buf(BFNO)+20,GROUP,NO)
NOTE: 20 is added to the start of the powepacker buffer as the .Abk
file which would be loaded into the buffer has a 20 character
header, and =Message$ must be passed the start of the bank.
Errors
------
If the bank name is not "Message " a Not A Message Bank error
occurs. An illegal function call occurs when:
- The group given does not exist
- The message number given does not exist in the given group
A "bank does not exist" error may also occur.
2.6 Strings and Integers
------------------------
= Long$(NUM)
This function loads an integer into a string. It is the equivilent
of:
a$=space$(4) : Copy varptr(NUM),varptr(NUM)+4 To varptr(a$)
It differs from str$, in that the integer is always stored in 4
bytes, as it is in memory. This makes Print #1,Long$(NUM) a good
way of writing integers to a file.
= Long(S$)
This is the compliment of the = Long function. It takes the first
4 bytes of a string, and converts them to an integer. It is useful
to read back numbers stored in strings with long$, or binary data
stored in a string.
NUM=Long(Input$(1,4)) is a usefull function call to read from a
file containing data created by Long$.
= Word$(NUM)
This is similar to Long$, but only stores the lower word of the
number. This means that Word$ should only be used for values
between -32768, and 32767. Its advantage is that the string
returned is only 2 bytes long, instead of 4
= Word(S$)
This reads back a word stored in a string. The value read from the
string is sign - extended, which is why it was said only to use
values between -32768 and 32767 with Word$.
You can, however, use word$ with values between 0 and 65535
instead, and use the following call to decode them:
NUM = Asc(S$)*256+Asc(mid$(s$,2))
Errors
------
Out of Variable Space No memory to create the string/
integer.
Illegal Function Call The S$ parameter was not a long
enough string (it must be at
least 2 bytes for Word, and 4 bytes
for Long).
2.7 Character Counting
----------------------
= Find Num Char(S$,A$)
= Find Num Asc(S$,A)
The syntax of these commands is very similar to that of the other
Find Asc/Char commands, but instead of returning the position of
the character A/A$ in the string S$, it returns the number of
times it occurs.
Errors
------
Illegal Function Call A is not between 0 and 255.
A$ is an empty string.
Section 3.0 Powerpacker Support
===============================
Easy Life provides 7 commands to allow you Load, and Save
powerpacked files. To use any of these powerpacker.library version
35 or greater must be in LIBS:
2.8 Multiple Occurances Characters
----------------------------------
= Find Nth Char(S$,A$,N)
= Find Nth Asc(S$,A,N)
This varient of find char/asc finds the Nth occurance of the
character A$/A in the string S$, or 0 if the string S$ does not
contain N occurances of A/A$.
3.1 Loading Powerpacked Data
----------------------------
The principle behind loading powerpacked data is:
1 Use PP Load to load & decrunch the data
2 Using PP Buf & PP Len to find the data
3 Perform whatever operations your program requires on the data
4 Use PP Free to return the memory to the system
Pp Load BUF,FILE$,DECRUNCH
This command will load a file into memory, then decrunch it, if it
was compacted with powerpacker. BUF is a number from 0-7 used to
choose which of the 8 buffers to load the file into.
NOTE: If the chosen buffer already contained data, it is freed
first.
NOTE: Pp Load will load uncrunched data without any problems, so
you don't have to worry about whether the file you are loading is
crunched or not. The only problem is if it was not crunched with
powerpacker.
FILE$ is the name of the file to load. It is important that the
full path be given, and that the file exists. E.g.
If F$<>""
If Exist(F$)
Pp Load 0,F$,2
Else
Print "File Not Found"
End If
End If
DECRUNCH must be an integer between 0 and 4, and determines what
happens when the file is decrunched. I recommend that option 3 is
not used with AMOS screens, but it does not generate an error
message, as your program may run on an intuition screen, if you
have an intuition extension.
0 : Flash colour 0 when decrunching
1 : Flash colour 1 when decrunching
2 : Flash colour 17 when decrunching (Mouse Pointer)
3 : Wobble Screen while decrunching (No effect on AMOS screens)
4 : Do nothing while decrunching
Errors
------
3.2 Reading the loaded data
---------------------------
Once data is loaded and decrunched with PP Load, you will need to
read it. The data is decrunched into one of 8 areas of memory
(buffers), numbered from 0 - 7.
=Pp Buf(NO)
Will return the address of the start of buffer NO
=Pp Len(NO)
Will return the address of buffer NO
You can used Peek / Poke / Deek / Doke / Leek / Loke to read the
buffer, and write to it (But don't write past pp Buf + pp len, as
this memory could be anything).
The buffer can be written back with either Bsave, or PP crunch.
You can also use mem$ to transfer the buffer contents to the AMOS
variable buffer. If the file is a text file, you can read it one
line at a time with:
Pp Load 0,file$,2
POS=0
While POS<Pp Len(0)
A$=Mem$(Pp Buf(0)+POS,Pp Len(0)-POS,10)
POS=POS+Len(A$)+1
'
'Now do whatever your going to do with A$
'
Wend
pp free 0
This segment of code will read the buffer up to asc code 10 (Line
Feed) into the string A$, and point POS to the next line. If no
Line Feed is found, the remainder of the buffer is next into A$
Errors
------
Pp Buf & Pp Len will cause an illegal function call if the buffer
no parameter is not between 0 and 7. If the chosen buffer is not
in use, both will return a 0.
3.3 Disposing of buffers
------------------------
When you've finish with a buffer, it must be returned to the system.
Pp Free NO
will return buffer NO (0-7) to the system. Future calls to Pp Buf
and Pp Len will return 0, until Pp Load is used to reserve the
buffer again.
NOTE: Under any of the following circumstances, ALL buffers are
Freed.
- You choose the Quit option from the AMOS editor
- Your compiled program (Run outside of AMOS) ends
- You use the System command
- You use the Default command
- You perform some other action (Such as running a program from
the editor) which causes AMOS to automatically do a Default.
Memory buffers are NOT freed, when your program ends, and returns
to amos, or an error occurs, and you return to amos. You can still
use Pp Buf & Pp Len, even after editing the program (Which clears
the AMOS variable buffer).
Errors
------
An illegal function call occurs if NO is not between 0 and 7.
No error occurs if you attempt to free an already free buffer.
This is perfectly OK to do, and won't cause a memory freed twice
guru (anymore!).
3.4 Saving Powerpacked Data
---------------------------
= Pp Crunch(FILE$,START<LENGTH),EFFICIENCY,BUFFER)
Easy life also allows you to save any block of memory, after
crunching it with the powerpacker routine. This does not use the
buffer system used by the other PP commands, but you can use Pp
Buf & Pp Len as the START and LENGTH parameters.
FILE$ = The name to save the crunched file to. It must have a full
path, and the directory must exist.
START, and LENGTH define the block of memory to save.
EFFICIENCY is an integer between 0 and 4 setting the crunch
effeciecy (0 = Fast, 4 = Best)
BUFFER is the size of speedup buffer to use. 0=Large, 1=Medium,
2=Small. If there is not enough memory for the buffer you choose,
a smaller one will be used
Pp Crunch will crunch & save the file, and return the length of
the crunched file.
Errors
------
"Out of memory" may occur if there if no memory for even the
smallest crunch buffer. An illegal function call occurs if you
pass an illegal EFFICIENCY / BUFFER value, or a 0 or negative
LENGTH.
Various I/O errors can also occur when saving the file.
3.5 Loading the library
-----------------------
PP Load & PP Crunch both require the powerpacker.libarary file.
However, to save memory, this file is not loaded until one of
these commands is used, and after the command is complete, the
library could be disposed of by the system if the memory it is
using is required. If the LIBS: directory will not be permanently
available, this may be inconvinent, so EasyLife provides a way of
keeping the library in memory.
PP Keep On
The command will load the library if it is not already in memory,
and then keep it there until you quit AMOS, or use the PP Keep Off
command.
PP Keep Off
This command informs the system that it is free to dispose of the
powerpacker library at its leisure.
NOTE: PP Keep Off does not remove the library, it just lets the
system remove it if it is necessary.
Section 4.0 - BITS and Pieces
=============================
4.1 Testing and setting
-----------------------
AMOS provides you with Btst,Bset,Bclr and Bchg instructions for
testing / setting individual bits. However, unless you are
changing the bits of an AMOS integer variable, these only work on
bytes. Easy Life provides coresponding commands for use with long
words & words.
NOTE: With all these commands, the second parameter is ALWAYS the
address to test/set, even if it is a variable name. The AMOS Bxxx
commands do not treat the second parameter as an address, unless
it is an expresion.
=Wtst(BIT,ADDR)
=Ltst(BIT,ADDR)
Both return TRUE if bit BIT of the Word/LongWord in address ADDR
is set, and FALSE if it is clear.
Wset BIT,ADDR
Lset BIT,ADDR
Set bit BIT of the Word/LongWord in address ADDR
Wclr BIT,ADDR
Lclr BIT,ADDR
Clear bit BIT of the Word/LongWord in address ADDR
Wchg BIT,ADDR
Lchg BIT,ADDR
Change bit BIT of the Word/LongWord in address ADDR. I.E. If it is
set, clear it, and vice versa.
4.2 Extension Extenders
-----------------------
= Extb(N)
= Extw(N)
These commands will sign extend numbers from bytes/words to long
words. To see what this means, imagine AMOS integers as 32 bit
binary numbers e.g. 42 is:
00000000 00000000 00000000 00101010
*
Sign extending from a byte (extb) looks at bit 7 (*) and copies
it's value into all the bits to it's left. This has no effect on
the number 42, but 139 is changed:
00000000 00000000 00000000 10001011
*
becomes:
11111111 11111111 11111111 10001011
AMOS will interpret the bit pattern as -117, as 10001011 is the
bit pattern for -117 in signed 8 bit arithmatic, but for 139, in
unsigned 8 bit arithmatic.
Extw copies bit 15 into all the places to it's left. Extb & Extw
can be used to translate signed bytes & words into AMOS integers.
Section 5.0 - I/O Commands
==========================
5.1 Protection
--------------
Easy life gives you two commands to reading, and changing the
protection bits of files and directories.
=Protect(FILE$)
This command returns the protection bits of FILE$ as an integer.
Set Protection FILE$,P
This command sets the protection bits of FILE$ from the integer P.
Interpreting the value of P
---------------------------
The protection bits are returned in the lower 8 bits of P. Their
meanings are given below. When using Set Protection, you should
only set these bits of P.
Bit Meaning Clear Meaning Set
0 Can be deleted Can't be deleted
1 Can be executed Can't be executed
2 Can be read from Can't be read from
3 Can be writen to Can't be writen to
4 File not an archive File is an archived
5 File not pure File Pure
6 File not a DOS script File is a DOS script
7 File visible in lists File hidden is lists
NOTE: Only bits 0-3 should be set on a directory NOTE: Bits 0-3
are the opposite of the ----rwed in directory lists. Bits 4-7 are
the same as hSpa----. This is so the default protection setting is
0.
Section 6.0 - Miscelanous Commands
==================================
6.1 The AMOS Data zone
----------------------
= AMOS Data
Returns the base address of the internal AMOS data zone. See the
file _equ.s in the extension folder of you AMOS Extras / AMOS
Updater disk.
= Easy Base(N)
This command is mainly for debugging EasyLife. The value returned
depends on the value of N.
N=0 Returns the base address of the EasyLife Data Zone. See
the source code for the structure of the data zone - it's
just after the first section of code.
N>0 Returns the RastPort AMOS is currently using.
N<0 Returns the address of the locked fonts structure
NOTE: The funciton of this command for N=0 will remain the same
in the future, but for other N, it's purpose may change - depending
on what part of the extension I have last been trying to debug!
6.2 Font Handling
-----------------
AMOS does not provide any way of ensuring a font is in memory, and
sometimes removes one from memory when you don't want it to.
Easylife can prevent this from happening.
Section 6.2.1 Locking Fonts
---------------------------
REALSIZE = Lock Font(FONTNAME$,FONTSIZE)
The lock font command checks if a font is in memory, and if it is
not attempts to load it from disk. If the font is now available, it
is locked, so it cannot be removed from memory by AMOS (Or anything
else).
FONTNAME$ is the name of the font to lock, and must end in ".font".
FONTSIZE is the size of the font to load from the disk, but with
some fonts, the size of the font listed in the FONTS: directory is
not the same as the actual size of the font, which appears in the
AMOS Get Fonts list. Therefore, Lock Font returns the actual size
of the font locked, so it can be looked up on the AMOS list.
Example
-------
The following procedure locks & returns the AMOS font number of
the given font:
Procedure FONT_NUM[N$,SIZE]
'
RS$=Mid$(" "+Str$(Lock Font(N$,SIZE)),1,3)
Get Rom Fonts : A=0
Repeat
Inc A
Until (Mid$(Font$(A),1,Len(N$))=N$) and (Mid$(Font$(A),30,3)=RS$)
'
End Proc[A]
NOTE: I Use Mid$(X$,1,L) instead of Left$(X$,L), because there
appears to be a bug in using Left$ with the compiler in some
situations.
Errors
------
An Unable to lock font error will occur if:
- You give a non-existant name/size of font
- The font is not in the directory assigned to FONTS:
- You have already locked 32 fonts
6.2.2 Unlocking Fonts
---------------------
Unlock Fonts
This command takes no parameters and unlocks all fonts that have
previously been locked. All fonts are also unlocked when:
- You use a Default Command
- You quit AMOS / A Compiled program
- You run a program within AMOS
NOTE: Unlocking a font does not remove it from memory, it just
permits other programs / commands to remove it.
Section 7 - Intuition Functions
===============================
7.1 - The Workbench
-------------------
AMOS provides a Close Workbench command, but does not provide a
way to check if it did actually close, or a way to open it again.
EasyLife to the rescue.....
= I Close Workbench
This function does exactly the same thing as the AMOS Close
Workbench command - closes the workbench screen, if not other
tasks are using it - but returns either:
0 - the workbench screen could not be closed
-1 - the workbnech screen was either closed sucessfully,
or was already closed.
= I Open Workbench
This command re-opens the workbench screen, and restarts the
workbench program, using the following algorythm:
If the workbench screen is already open, nothing happens, and
a value of -1 is returned.
EasyLife then attempts to open the Workbench screen.
If this fails, a value of 0 is returned
If the screen opened, and the LoadWb command has been used, the
workbench is restarted.
If the screen opened, -1 is returned
= I Test Workbench
This function returns -1, if the workbench screen is open, or 0
if it is closed.
Side Effect
-----------
I Close Workbench & I Test Workbench have the side effect of
bringing the workbench screen to the front of all other intuition
screens (But not in front of AMOS Screens). This means:
- If I Close Workbench fails, the workbench screen will be put in
front of other screens.
- After an I Test Workbench, the workbench screen is brought to
the front if it is open. You may like to call I Test Workbench
simply for this purpose after an I Open Workbench.
7.2 Iconifying AMOS
-------------------
A = Iconify Amos(X,Y,TITLE$)
This command opens the workbench screen, and opens a small window
on it at co-ordinates (X,Y) with the name TITLE$. It has a close
window gadget, and depth gadget(s), and is moveable.
If you activate the window, then press the right mouse button, or
you press the close window gadget, the window is closed, and the
following value is returned.
-1 = The close window gadget was pressed
0 = Then right mouse button was pressed with the window active
1 = Couldn't open workbench screen (Usually no chipmem)
2 = Couldn't open window (Usually illegal co-ordinates)
NOTE: This command suspends your AMOS program until the window is
closed
Using Iconify AMOS
------------------
It is recommended that you always use the following procedure to
call iconify amos:
Procedure ICONIFY[X,Y,TITLE$]
Amos Lock
Amos To Back
A=Iconify Amos[X,Y,TITLE$]
Amos To Front
Amos Unlock
End Proc[A]
The Lock/Unlock disable Left-Amiga-A switching, as the program is
frozen while the window is displayed. An alternative method is to
lock amos at the start of your program, and leave it locked, and
remove the lock/unlock commands from this procedure.
Is possible you should close your AMOS screens when iconifing, as
this saves some memory.