×   Main Menu ALL The 8BS News Manuals (New menu) Links Worth a Look Tools Disc and Basic Webring Site Map 8BS Guestbook Old Guest Book Me The Barnsley Rovers   
8-Bit Software

The BBC and Master Computer Public Domain Library

B2C8 SOUND

Submitted by Steve Fewell

Description:

Get the result of the expression at BASIC Text Pointer A and convert the result to Integer (if Float), or issue a
'Type mismatch' error (if String value found).
Set X to 3 (as we have 4 parameters to obtain).

Loop for X number of times. For each loop:
* Push the Integer result (next parameter) LSB 2-bytes (&2A-&2B) to the Stack.
* Temporarily push X to the stack
* Check for "," (comma) charater (issue "Missing ," error if not found), and get the Integer result of expression at
     BASIC Text pointer B.
* Retrieve X from the stack.
* Decrement X value.
* If X is not 0 yet then loop again.
Now, we have the first 3 parameters on the stack and the last parameter in the IWA (&2A-&2B).

Call routine &9B96 to check that the Statement terminates correctly (if not, then a 'Syntax' error is issued).
Store the last parameter (IWA locations &2A-&2B) in locations &3D-&3E (LSB value (&2A) first).
Set Y to 7 (OSWORD call number for SOUND).
Set X to 5 (Number of parameter bytes left - 1). Each Sound parameter is 2-bytes wide.

Call routine &B307 to do the following:
* Pop the last Byte from the stack and store in location (&37 + X), i.e. location &3C for the MSB of the 3rd SOUND parameter).
* Decrement X and keep repeating from &B307 until X is negative.
* Now location &37 to location &37 + Original X value + 2 (i.e. &3E for SOUND parameter block) contain the
   OSWORD call parameters.
* Set A to Y value (the number of the OSWORD call).
* Set X to #&37 and Y to #&00 (as the start of the parameter block is &0037).
* Call the Operating System OSWORD routine (&FFF1) to perform the required operation.
* Jump to &9005 to start processing the next Statement (if any).


Disassembly for the SOUND routine

B2C8 o 032 111 146 20 6F 92 JSR &926F Evaluate Expression at BASIC Text pointer A & convert result to integer
B2CB   162 003 A2 03 LDX#&03
B2CD * 165 042 A5 2A LDA &2A
B2CF H 072 48 PHA
B2D0 + 165 043 A5 2B LDA &2B
B2D2 H 072 48 PHA
B2D3   218 DA PHX
B2D4   032 172 150 20 AC 96 JSR &96AC Check for ',', get result of expression and convert result to Integer
B2D7   250 FA PLX
B2D8   202 CA DEX
B2D9   208 242 D0 F2 BNE -14 --> &B2CD
B2DB   032 150 155 20 96 9B JSR &9B96 Check for end of Statement (PTR B)
B2DE * 165 042 A5 2A LDA &2A
B2E0 = 133 061 85 3D STA &3D
B2E2 + 165 043 A5 2B LDA &2B
B2E4 > 133 062 85 3E STA &3E
B2E6   160 007 A0 07 LDY#&07
B2E8   162 005 A2 05 LDX#&05
B2EA   128 027 80 1B BRA 27 --> &B307 Create Parameter Block, call OSWORD & process next Statement

 


 Back to 8BS
Or