************************* THE A M O N Extension ************************* A FryUp Productions Product For Amos/Pro ======================================== Version 1.04 By Paul Overy 22/8/1995 (last update) Install Notes: -------------- - Run the Interpreter/config program. - Load the default config & then enter the loaded extensions. - Enter the name of the new extension in >>>slot 25<<< Type "AmosPro_Amon.lib". ------------- - Save the new configuration. - Use Workbench/AmigaDos to Copy the "AmosPro_Amon.lib" library into the APSystem draw. Examples can also be found on the disk. Why More Mouse/keyboard Commands? --------------------------------- Amos can be sped up by throwing out the multitasking system. Lets face it, how often do you make use of the multitasking system when playing a game? However this does have one bad side effect in that, mouse control is lost. In fact all Amos mouse/keyboard commands because useless. Amos Classic gives a greater speed up with multi off, as AmosPro still lets mouse/keyboard codes trickle through and these are not really frequent enough to use. How do I turn off the multitasking system? MAKE USE of these two lines:- ======== Break Off : NUL=Execall(-132) :Rem Multitasking Off NUL=Execall(-138) : Break On :Rem Multitasking On Place multi Off at start of your code & Multi On at end of your code. Its also a good idea to use "Break Off" before multi off. Then Ctrl-c will have no effect, so you can't break into the editor & crash it with multitasking off. WARNING: If your program throws up an error, with multitasking still off, you MUST go into direct mode straight away, and turn it back on with nul=execall(-138). Its really best to code with those two lines commented out, and include them once you have finished. COPYRIGHT © NOTES: ----------------- This package is SHAREWARE. It's the full version so far with no pop up messages. * No charge is required if Amon is used under the editors interpretor. * However a small fee is required when using the extension in independent compiled code. For registration, send £5 (sterling) with a disk & S.A.E. A first class stamp will cover the return journey of 60g. The £5 fee can be paid in hard cash or a cheque in my name (PAUL J OVERY) Anyone outside the UK will have to send cheques, for the sum of £7.50 the extra 50% being the bank conversion fee. (Future updates are free, but required a S.A.E + disk) If anyone wants slot number 25 changed, just ask. My Name & address, ----------------- PAUL OVERY 27 Barton Road Maidstone Kent ME15 7BU ENGLAND. Please clearly state you wish to register for the Amon Extension. *** All thoughts & ideas are welcome *** DISCLAIMER ---------- I cannot be held responsible for any damage to you, your computing equipment, your programs, or any data as result of use the Amon extension, either directly or consequentially as a result of its use. By using the Amon extension you agree to these terms and agree not to hold me liable for any damages arising from use of this package. Use the Amos extension package at your own risk. HISTORY ------- V1.00 - Private version. V1.01 - First public version, released as Shareware. - 17/7/95 - New command added, Set Angle Bank. - Fixed small bug in Fast Angle. Now reports top angles OK. - Fix negative sin/cos values, now returned in longword format. Plotting these values worked fine, later the print command did however reveal the problem. It seems that the plot command reads its coordinates word size, this error had me puzzled for some time. (Bed time 1.45am) - 18/7/95 - "Amon_bank.10" was 35k, now only 2.44k. Fast Angle routine now handles better scaling. - Added User scaling to Fast Angle Routine. Syntax now: =Fast Angle(X1,Y1 to X2,Y2,SCALE) - Recalculated Table & updated angle routine to make better use of whole bytes. Angle resolution is now very much better. (Bed time 3.00am) - 19/7/95 - Placed "Amon_bank.10" table in extension code. - Removed the Set Angle Bank command. - Added more safe guards & error messages. (PUB TIME) - 20/7/95 (back from pub) - SinCos table data now shared, saved 182 bytes (every little bit helps). - Bed time (1.32am) V1.02 - 23/7/95 - New command added, Rodent Key. - New comandd added, Set Rodent. - Added option to leave out x1,y1 paramaters from Fast Angle Now it can also use current rodent x/y values instead. V1.03 - 6/8/95 - Code optimised in places. - Fixed bad addressing of Amon DataZone, kindly pointed out by Manuel Andre. Stay away from versions below 1.03. - New command added, Fast Plot. - New command added, Test Add. - New command added, Fast Circle. - 10/8/95 - Sped up Fast Circle some more. - New command added, Array Plot. - Added 4 player joystick commands. (not yet tested!!!) - 22/8/95 - Array plot can now accept just a single colour. - 27/8/95 - Added Fast Point command. - Added Count Line command. - 28/8/95 - Change Count line to Count Colour - Also added Find Colour. V1.04 - 13/9/1995 - Change slot from 16 to 26. I hope you all enjoy using Amon, any bug reports (however small) to my address. PLEASE NOTE: ============ When upgrading to a newer version of Amon, it is important that you save all your Amos programs in Ascii format. Sorry I know its slow, but this must be done. Loading old Amon commands into a newer version will confuse the editor, as the newer commands may have extra paramaters. -------------------------------------------------------------------------------------- -- COMMAND LIST -- =Rodent X Function Rodent X has a faster setting than normal Amos. Works fine with multitasking off. Example: VALUE=Rodent X Also see, "Limit Rodent(x1,y1 to x2,y2)". __ =Rodent Y Function Rodent Y has a faster setting than normal Amos. Works fine with multitasking off Example: VALUE=Rodent Y Also see, "Limit Rodent(x1,y1 to x2,y2)". __ Limit Rodent x1,y1 to x2,y2 Instruction to Limit Rodent X & Y values to a rectangular area. Values can be in software or hardware coordinates, depending if you wish to display a sprite or bob type mouse pointer. A Lowres screen is default at run time. Example: Screen Open 0,640,256,4,Hires Screen Display 0,128,42,, Limit Rodent 128,42 to 128+640,42+256 - The above code will lock Rodent X/Y values inside the screen. __ =Lrodent This function Checks for a left mouse button. Works fine with multitasking off. Returns True (-1) or False (0). Example: If Lrodent Then Print "Left Mouse" __ =Rrodent This function checks for a right mouse button. Works fine with multitasking off. Returns True (-1) or False (0). Example: Do If Rrodent Then Print "Right mouse" Loop __ =Rodent Key The rodent key function enables you to check whether one or more of the mouse keys have been pressed. It returns a bit-pattern which holds the current status of the mouse buttons. Unlike the Amos Mouse Key this works fine with multitasking off. This bit-pattern has the following format: Bit 0 Set to 1 if the LEFT button has been pressed, otherwize zero. Bit 1 Set to 1 if the RIGHT button has been pressed, otherwize zero. i.e. Left down=%01 , Right down=%10 , both=$11 = 1 = 2 = 3 Amos/pro supports a 3 button mouse, AMON however does not. This could be included if you need it? Exemple. If Rodent Key=3 Then Print "Both Buttons" If Lrodent and Rrodent Then Print "Both buttons" -- Set Rodent X,Y Use the Set Rodent command to reposition the Rodent x/y coordinates. The values will still be restricted to that set by the Limit Rodent command. Example: Set Rodent 100,100 -- =Keycode This function acts just like the normal Amos/Pro Scancode command. However this works fine with multitasking off, and does not require A$=Inkey$ before hand. Keycode will return 0 with no keyboard inputs. The return value can be used to test a specific button with "=Key press(Value)". __ =Key press(Value) This function checks if a specific key has been pressed. Works fine with multitasking off. Value is the internal scancode (or keycode) of the key you want to check. When the key is pressed down, then Key Press will return a value of TRUE (-1). Otherwise the result will be FALSE (0). Example: Do If Key Press(69) Then Print "Esc pressed" Loop __ Video Wait VALUE The Video Wait instruction helps in accurate screen synchronization, by waiting until the video beam has reached a given value. If the screens vertical beam is already greater than VALUE, then there will be no wait. Value needs to be in hardware coordinates. Say you have a scrolly message at the top of the screen which was 16 pixels high, and the rest of the screen was a still picture. Then use: Video Wait Y hard(16), with no need to double buffer the screen. Unlike the (very good) Turbo+ extension instruction "Vbl Wait ". This does not wait, when the beam has already passed the value. Video Wait should be used BEFORE a Screen swap, unlike the Amos Wait Vbl which goes after the Screen swap. __ Fast Joy0 X,Xstep,Y,Ystep This instruction adds or subtracts the correct stepping value from the two variables, depending on the joysticks movement. This will dramatically speed up & cut down joystick control code. NOTE: Make sure you point to the variables address, they could be stored at the start of your code. i.e. Y=100:ADR_Y=Varptr(Y) X=100:ADR_X=Varptr(X) ... ... ... Fast Joy0(ADR_X,1,ADR_Y,1) Working Example: X=100 Y=100 Do Fast Joy0 Varptr(X),1,Varptr(Y),1 Plot X,Y Wait Vbl Loop __ Fast joy1 X,Xstep,Y,Ystep See Fast Joy0. __ =Joy3 See Joy4. (note these two commands have no yet been tested) __ =Joy4 These two commands check for a 4 player adapter. The state of the two extra joysticks can be read by inspecting the pattern of bits in the result. Result meanings:- ================================== Bit Number Significance ================================== 0 Joystick Up 1 Joystick Down 2 Joystick Left 3 Joystick Right 4 Fire Button ================================== How to build a 4-player adapter for MasterBlaster etc... Joystick 3 parallel Port ---------- ------------- pin 1 -------------------- pin 6 pin 2 -------------------- pin 7 pin 3 -------------------- pin 8 pin 4 -------------------- pin 9 pin 5 -------------------- NOT USED pin 6 -------------------- pin 13 pin 7 -------------------- +5 V pin 8 -------------------- GND Joystick 4 ---------- pin 1 -------------------- pin 2 pin 2 -------------------- pin 3 pin 3 -------------------- pin 4 pin 4 -------------------- pin 5 pin 5 -------------------- NOT USED pin 6 -------------------- pin 11/12 pin 7 -------------------- +5 V pin 8 -------------------- GND __ =Fast Angle(X1,Y1 to X2,Y2,SCALE) =Fast Angle(X,Y,SCALE) ; uses current rodent coordinates for point A. The Function returns a frame image for Bob B to face Bob A. Return Values are from 1 to 576, true angles are not returned but can be very easily calculated. X1,Y1 = Bob A X2,Y2 = Bob B SCALE is a value used to divide (logical shift) the result. Range returned SCALE=0 No scale ........................................ 1 to 576 SCALE=1 Divides Fast Angle result by 2 .................. 1 to 288 SCALE=2 " " " " 4 .................. 1 to 144 SCALE=3 " " " " 8 .................. 1 to 72 SCALE=4 " " " " 16 .................. 1 to 36 SCALE=5 " " " " 32 .................. 1 to 18 SCALE=6 " " " " 64 .................. 1 to 9 NOTE: 2^SCALE will give the divide amount. i.e. The result can be directly used for a bobs/sprite image:- RESULT=Fast Angle(BAD_X,BAD_Y to X_COORDS,Y_COORDS,3):Rem Which frame? 1..72 Bob 0,X_coords,Y_coords,RESULT When using the short version of this function Fast Angle(X,Y,SCALE) which locks onto the Rodent, make sure you still call Rodent X & Rodent Y to update their values. The routine may scale down the inputs, effecting the resolution between the two points. It scales the inputs by half, until they can be directly used to index internal data. The larger the difference the more they are scaled. This still gives excellent resolution for games. A <--------- (x1,y1) A \ \ | \ \ |* \ *\ |** \ **\ |** \ ****\ |*** \ *****\|*** B <-- (x2,y2) ***** B ** ******** ******** ****** 315° by formula or 504 The above shows correct input order for "B" to face "A". i.e. if Fast angle result = 504 This can be change into a real angle, by:- (504/1.6) = 315°; shown in the diagram. i.e. 576/360°=1.6 Also see Working Example for more detail. You may ask, why not just return the angle? - Well, this routine was designed for returning a image number. - So that the result could be directly used as a bob/sprite image number. As the routine stands, 576 image turning frames are supported. I can't see anyone using more than 36 (scale 4) or 72 (Scale 3) turning images. A bullet firing method you might like to try is: Use the result from fast angle to direct a accurate bullet firing system, the total amount of bullet images needed is only half the result or even less. In the example 144 coordinate firing angles are used, with only 72 image frames. This gives the bullet a better aim over a longer distance. To do this just store your x,y stepping offsets in two X/Y Array's, as shown below. '-- Store Bullet paths Dim BULLET_X(144),BULLET_Y(144) K=37 : N=0 : A=2 Do BULLET_X(K)=Int Cos Mul(N,32) : BULLET_Y(K)=Int Sin Mul(N,32) Plot BULLET_X(K)+32,BULLET_Y(K)+32 :Rem test part, draws circle? A=5-A : Add N,A Exit If K=36 Add K,1,1 To 144 Loop ....NOW CUT OUT 36 BOB IMAGES, WHICH ROTATE IN A FULL 360° CIRCLE. (You may need to rotate a bob in Dpaint to get that) Then, find the angle you wish to fire to. Directly index both array's with the returned number, this gives the amount to add on the x & y coordinates of the bullet. RESULT=Fast Angle(BAD_X,BAD_Y To YOU_X,YOU_Y,2) :Rem 2=divide result by 4 Add BULLET_X,PX(RESULT) Add BULLET_Y,PY(RESULT) Half the result again to give a bullet image frame. Bob 0,bullet_x,bullet_y,result/2 If your image has less turning frames, then divide down the result. The above method has been rather crude, giving large movements. It would be best to use the array contents to set up an Amal channel to control firing. (don't use floating point arithmetic to move objects smoothly across the screen,it takes far too much CPU time) --------------------------------------------- Example1: Real number Angle Conversion. Screen Open 0,320,256,2,Lowres Double Buffer : Autoback 0 Hide : Limit Rodent 0,0 To 320,256 X2=160 : Y2=128 Do X1=Rodent X : Y1=Rodent Y Draw X1,Y1 To X2,Y2 Text X1,Y1,"B" Text X2,Y2,"A" A=Fast Angle(X2,Y2,0) '-- Same as... A=Fast Angle(X1,Y1 To X2,Y2,0) Text 10,10,"Image="+Str$(A) Text 10,20,"Angle="+Str$ (A/1.6)+"°" Screen Swap : Wait Vbl : Cls 0 Loop --------------------------------------------- Example2: Angle in 10° ANGLE=Fast Angle(X1,Y1 to X2,Y2,4)*10 --------------------------------------------- Example3: Angle in 5° ANGLE=Fast Angle(X1,Y1 to X2,Y2,3)*5 --------------------------------------------- Example4: Angle in integers. ANGLE=Fast Angle(X1,Y1 to X2,Y2,0)*5/8 --------------------------------------------- Example5: Image numbers 1 to 72 ANGLE=Fast Angle(X1,Y1 to X2,Y2,3) --------------------------------------------- Example6: Image numbers 1 to 576 ANGLE=Fast Angle(X1,Y1 to X2,Y2,0) --------------------------------------------- __ =Mul Sin(Theta,Multiplier) A function to return a integer, for Multiplier * sin(theta). This is a fast fixed point routine, real numbers are not returned. Amos equivlant: RESULT=Int(sin(THETA)*MULTIPLIER) Amon Syntex: RESULT=Mul Sin(THETA*MULTIPLIER) Woring Example: PAL#=50.0 ITERATIONS=20000 Degree :Rem -- Only neded for Amos Cos/Sin ' Print "TESTING..." ' Timer=0 For K=0 To ITERATIONS A=Sin(22)*33 Next K Print "Amos Sin ";Timer/PAL#;"seconds" ' Timer=0 For K=0 To ITERATIONS A=Mul Sin(22,33) Next K Print "Amon Integer Mul Cos ";Timer/PAL#;"seconds" __ =Mul Cos(Theta,Multiplier) A function to return a integer, for Multiplier * Cos(theta). This is a fast fixed point routine, real numbers are not returned. Amos equivlant: Result=Int(Cos(THETA)*MULTIPLIER) Amon Syntex: RESULT=Mul Cos(THETA*MULTIPLIER) Working Example: PAL#=50.0 ITERATIONS=20000 Degree :Rem -- Only needed for Amos Cos/Sin ' Print "TESTING..." ' Timer=0 For K=0 To ITERATIONS A=Cos(22)*33 Next K Print "Amos Cos ";Timer/PAL#;"seconds" ' Timer=0 For K=0 To ITERATIONS A=Mul Cos(22,33) Next K Print "Amon Integer Mul Cos ";Timer/PAL#;"seconds" __ Fast Plot X,Y,Colour This instruction acts just like the normall Amos Plot command, but its much faster. __ =Fast Point(X,Y) This instruction acts just like the normall Amos Point command, but its much faster. __ Fast Circle X,Y,Radius,Colour This command draws a hollow circle using the radius and centre point X,Y. Fast circle is many times faster than the Amos circle command, it also does not give bad results with negative radius values. A radius of zero is permitted, giving just a single pixel. __ Array Plot X(),Y(),Colour(),N Array Plot X(),Y(),C,N The array plot instruction allows many points to be plotted at great speed. This is much the same as the normal plot command, but here values are taken from three different arrays. The third colour array may be a colour value. N is the amount of array elements to be taken into account starting from 0. Example: Dim X(100),Y(100),C(100) For K=0 to 100 X(K)=Rnd(320) Y(K)=Rnd(200) C(K)=RND(15) Next K Array Plot Varptr(X(0)),Varptr(Y(0)),Varptr(C(0)),100 ^ ^ ^ ^ | | | | ------------+------------ | Start Element N (count from 0 to 100) Array plot in Amos looks like this:- For K=0 to 100 Plot X(K),Y(K),C(K) Next K As Long as you start your index at zero, i.e Varptr(X(0)) you can regard N as the last index to be reached. Note: Amos may not have enough variable space. So when using large ararys, extra space can be reserved with Set Buffer. WARNING: Make sure you point to each Array with Varptr(). DON'T let N exeed to array limit. __ =Count Colour(X1,Y1 To X2,Y2,Colour) This command scans along a line counting a specific pixel colour. Example: _Col3=Count Colour(10,10 To 100,100,3) Uses: For detecting if a long laser blast has hit anything. To do this, use the Count Colour command just before the laser blast is draw. NOTE: If (X1 And X2)=(Y1 And Y2) then nothing will happen. __ =Find Colour(X1,Y1 To X2,Y2,Colour) This command scans along a line until it finds a specific coloured pixel. The result is the distance in pixels between the starting point and the point at which the colour was found. Example: DISTANCE=Find Colour(10,10 To 100,100,3) Uses: Acts just like Count Colour, but here a position is returned for say an explosion or a miss which has hit a wall. Find Colour is faster then Count Colour, as the command returns a value as soon as something is found. NOTE: If (X1 And X2)=(Y1 And Y2) then nothing will happen. __ Test Add Test_Array(),Array(),Test,Value,N This instruction will add Value to Array() if Test_Array()=Test. N is the number of array elements to take into account starting form 0. Example: Dim TEST_ARRAY(10),ARRAY(10) ... ... ELEMENTS=11 : rem 0 to 10 gives 11 TEST=1 : VALUE=100 Test Add Varptr(TEST_ARRAY(0)),VARPTR(ARRAY(0)),TEST,VALUE,ELEMENTS The same thing in Amos Dim TEST_ARRAY(10),ARRAY(10) ... ... ELEMENTS=11 : TEST=1 : VALUE=100 For INDEX=0 to ELEMENTS IF TEST_ARRAY(INDEX)=TEST ADD VALUE,ARRAY(INDEX) END IF NEXT INDEX WARNING: Make sure you point to each Array with Varptr(). DON'T let N exeed the array limit. Notes: ------ * All the Array Commands may also use Amos/Pro banks, to do this store the values inside a bank in Longword format. (4bytes/32bits) Look up Leek, Loke and Reserve As bank, if your not quite sure how to do this. * Some other extensions may offer a VALUE=Range(VALUE,0 to 100) type function. But by using the normal Amos/Pro Max & Min commands, the same type of function can be defined. i.e. VALUE=Max(Min(VALUE,100),0) will do the same job at greater speed. The Amos code for this function would be: If VALUE>100 VALUE=100 Else If VALUE<0 VALUE=0 End if Infact the Amos/Pro code will run faster than an extra command, as an extension command has a small overhead in time when its called. * End-Of-Doc *