I need an answer on the following problem: I know that Sprint doesn’t handle floating point numbers such as Sin Cos etc, so I was wondering if the following solution could be possible:
1. I write the body of the program in Basic.
2. The lines that handle the Sin Cos calculations, also gets written in Basic, but in the form of reading and poking using a for-loop. (It’s my guess that the Sin and Cos will be READ in as tokens or something like that. That way the Sprint Compiler won’t complain, or am I wrong here?)
3. Then I compile the program using Sprint and it works,… right? Hmmm…. I am aware that the Sprint won’t really improve the Sin/Cos calculation speed, but at least I want to improve on the graphics’ display speed, etc.
4. According to the Sprint Compiler Instructions, and I quote:
If Sin Cos can be done by reading and poking using a for-loop in Basic (and then compiling using Sprint), can someone please write the following lines so that it can be placed into a numeric array for machine code purposes – the type where you read hex in Basic and poke it into some addresses using a FOR LOOP (like the machine code routine example that was used above to invert the text screen):3.9 MACHINE CODE PROGRAMMING:
In this section we look at the layout of compiled program and how machine code may be incorporated into compiled programs.
3.9.1 PROGRAM LAYOUT:
A program compiled by OASIS BASIC will use all the RAM memory except that reserved by PCLEAR.
A program containing PCLEAR 0 will use all available RAM.
A program containing no PCLEAR will use all memory except graphics pages 1 to 4.
With OASIS BASIC the CLEAR command is ignored and cannot be used to reserve memory for machine code routines. Any attempt to place machine code at the top of RAM will corrupt the compiled program and have an unpredictable effect on the execution of the program.
3.9.2 MACHINE CODE STORAGE: page 12....
A machine code routine can still be used with OASIS BASIC by either placing it in a reserved graphics page or by reading it into a numeric array within the program. If code is to be placed into a numeric array we must place two bytes per component, i.e we must assign a value (256* byte one + byte two) to each component of the array.
**** For example, the following machine code routine can be used to invert the text screen****
8E, 04, 00, A6,84 ,81,80, 25, 04, 88, 0F, 20, 02. 88, 40, A7,80, 8C 05,FF,23,ED,39
We can either read it into a graphics page (say page 1) or we can read it into a numeric array (say X). Since this routine has 23 bytes the array will need 12 components, i.e DIM X(11).
310 FOR T= 0 TO 25 STEP (1/10)
320 G=16+(V*T*(SIN(A/57)))
330 O1=V*T*(SIN(A/57))-(((5/10)*((98/100)*(T to the power of 2))))
450 NEXT T
Remember Sprint only works with integers, therefore 0.1 is represented by (1/10) and 0.5 will be (5/10) in code.
Now I don't know if the lines starting with 340 PSET(G9,O9,C9) and all the IF STATEMENTS up to 440 should also be written using the loop-read-poke sequence? These in between lines 340-440 deals with the IF’s and THEN’s.
Also the enemy’s calculations are done on the following lines:
770 FORC T= 0 TO 25 STEP (1/10)
780 CG=238-(CV*CT*(SIN(CA/57)))
790 OC=CV*CT*(SIN(CA/57))-(((5/10)*((98/100)*(CT tothepower2))))
910 NEXT CT
Again I left out the line 800 PSET(GC,OO,CB) and the IF – THEN statements from 810 to 900 – don’t know if it should it also be written using the loop/read/poke system?
Hope to hear from someone soon.
Regards, Cloete