home *** CD-ROM | disk | FTP | other *** search
- 157
- aaa00000ff00fe0080333fff001
- ^2()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
-
- ^6[5HINTS & TIPS FOR BETTER PROGRAMMING.[0
-
- ^2()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
-
- ^7 Please note that most of the tips & hints are for Amos V1.3 and
- ^7above. To get the best from Amos, and avoid a lot of programming
- ^7problems, it is important to update to the latest version of AMOS.
- ^7This is always available from:-
-
- ^2DEJA VU SOFTWARE,
- ^2C/O SANDRA SHARKEY
- ^225, PARK ROAD,
- ^2WIGAN WN6 7AA.
-
- ^7.....................................................................
-
- ^2 This tip sounds good, but we haven't been able to test it yet, we'll
- ^2let you know what happens in the next issue.
-
- ^6 Sometimes when you are writing a program, one procedure can slow
- ^6the whole program down. We have heard that you can compile a
- ^6single procedure then run it from a Basic listing. This will speed
- ^6up an otherwise slow part of your listing.
-
- ^7.....................................................................
-
- ^4 We hope that the next tip will help you avoid a major problem we
- ^4came across when we first started using the Compiler, we hope it will
- ^4save you the frustration we've suffered over the last couple of
- ^4months!
-
- ^6 Most of our programs have needed a random number generator for
- ^6various reasons, and we have been using the same one without any
- ^6problems......until the Compiler came along. A problem was spotted
- ^6when we were beta testing the compiler, none of our programs would
- ^6compile, whereas most other programs did. We didn't know why for a
- ^6long time.
-
- ^6 The problem got really frustrating when Marvin The Martian needed to
- ^6be compiled in order to get better gameplay & speed. It kept
- ^6crashing after just a minute or two.
-
- ^4 The answer came by chance while working on another program. The
- ^4only thing that all our problem programs have in common is that the
- ^4random routine uses the RND command inside a loop.
-
- ^2 It seems that the compiler does not accept the program if it loops
- ^2around the Rnd command.
-
- ^7.....................................................................
-
- ^6 If you have come across any problems like this where things work OK
- ^6in Basic, but not when compiled, let us know, even if you have not
- ^6found the answer!!
-
- ^4 If you haven't got you copy of The AMOS Compiler as yet, why not try
- ^4our competition? It's easy to enter, we give you all the answers,
- ^4you just have to pick it out from the choice of three we've given!
- ^7...................................................................
-
- ^6{7USING THE RAM DISK IN YOUR PROGRAMS.{
-
- ^4[5Help given by ^2SPARX.[0
-
-
- ^2[5WHAT IS A RAM DISK?[0
-
- ^1 A Ram Disk can be used in the same way as a floppy disk, with the
- ^1following differences.
-
- ^21. ^7As will be explained later, a ram disk is dynamic, it is only the
- ^7size that is needed, ie if you save a small file to ram, the disk
- ^7will not have any wasted space as you would have on a floppy disk.
- ^7For example, if the files you put onto ram come to 50,000 bytes, then
- ^7the ram disk will be 50,000 bytes, no waste!
-
- ^22. ^7The data is stored in Fast mem, not in a drive, so that there is
- ^7a great advantage to storing graphic data.
-
- ^23. ^7Data stored on a ram drive, will NOT survive a guru or a reset as
- ^7data on a floppy does.
-
- ^6 This tip is only relevant if you are writing programs for users who
- ^6have ^21 meg or more. ^5It will [2NOT [0work in a 1/2 meg machine.
-
- ^4 Using a ram disk is a great way to store your graphic data during
- ^4the run time of your program as you will not have to wait while the
- ^4new graphics are loaded in.
-
- ^6 This I have done several times in the past with great sucess, if you
- ^6wish to try this out, then read on!
-
- ^1 First make sure that the ram handler and the ram device are on your
- ^1AMOS disk, to check, look in the devs and l directories. If they are
- ^1missing, then copy them from your workbench disk into the relevant
- ^1directories, not forgetting that these files will also have to be on
- ^1the disk that holds your finished program!
-
- ^2 Once you have checked for these files, it is very easy to create
- ^2your ram disk.
-
- ^5 You can do this either from the cli, or directly from AMOS itself.
-
- ^7 To do so inside AMOS, all you have to do is put in this line
- ^7somewhere inside your initialisation routine.
-
- ^2RM=Exist("ram:")
-
- ^7 It's as simple as that!
-
- ^2 When AMOS meets this command, it looks at your disk to see if the
- ^2ram handler is available, if it is, it will create the ram disk for
- ^2you. Once the ram disk is created, you can now load in your graphic
- ^2files whatever they may be, screens, bob banks etc and immediately
- ^2they have been loaded save them to ram: then delete the bank etc.
-
- ^2eg Load"bobs.abk"
- ^2Save"ram:bobs.abk",1
- ^2Erase 1
-
- ^5 Carry on like this until all your graphic files are in ram. Once
- ^5they are safely in ram, you can load each bank or screen etc as it is
- ^5needed with next to no loss of time, it's almost as fast as a hard
- ^5drive. I have used it sucessfully in several programs and it hasn't
- ^5let me down yet.
-
- ^6 This gives the illusion that all the graphics are in memory, as
- ^6there will be no drive access, also that there are far more graphics
- ^6in memory than the machine is physically capable of handling.
-
- ^7 There are limits to how much can be put onto a ram disk, so keep an
- ^7eye on the byte size of your files.
-
- ^2 Using a ram disk will take a bit of experimenting, but it will be
- ^2worth it in the end when you think of the advantages.
-
- ^4 An example of how a ram disk is used can be found in SHYMER, LPD 30.
- ^4This is an illustrated adventure where the picture changes each time
- ^4you move to a new location. Having seen the original version where
- ^4the disk access slowed things down no end, I suggested that the ram
- ^4disk was used, the difference was amazing! You can now ove around
- ^4from place to place without waiting ages for the drive to catch up
- ^4with the game-play!
-
- ^1 As a tip, while you are writing your program, REM or leave out the
- ^1save to ram until you have finished. This is because leaving it in
- ^1will cause the program to load your files and save them into ram
- ^1every time you test your program, this will take up a lot of time if
- ^1you test your program frequently, as is normally the case.
-
- ^2 If you have any problems, drop us a line and we'll see what we can
- ^2do!
-
- ^6()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
- \
-