| QTIPS - DOSTime |
| VERBatim - V11 |
| @ATTACK - @Backgrnd.Time |
| @ATTACK - @Index.Time |
| QTIPS - Time-outs in Windows |
| SecureUser |
| VERBatim - V25 |
| @ATTACK - @Files.System |
| Advanced Revelation Initialisation Sequence (Overview) by Mike Pope |
| REVMEDIA Revisted |
| Reader's Clinic - Screen Width |
| Screen Grabber |
| Reader's Clinic - Slow Multivalued Screen Display |
| Utility Diskette # 4 |
| VERBatim - V119 |
| VERBatim - V125 |
| VERBatim - V118 |
| Advanced Revelation Assembler Interface Module - Yves Pattyn, Technical Manager, Distribase, France |
| Vroom |
| RTP Series - RTP5 |
| VERBatim - V15 |
| Play it Again, Cam |
| QTIPS - BASIC Options |
| Utility Diskette # 4 |
| Reader's Forum - Mark Hirst Revelation C Interface - Part 1 |
| Reader's Forum The C Interface Part 2 - Mark Hirst (Senior Techie - ICS) Reader's Clinic |
| Play it Again, Cam |
| QTIPS - Runtime Version |
| Reader's Forum - Numeric Precision in R/Basic - Hal Wyman |
| Playing with Scan Codes |
| QTIPS - Compiling Protection Code |
| QTIPS - Invalid Code and Command |
| QTIPS - Code/Command Help |
| Compiling 64K on a Shoestring by Blaise Wrenn (LexStat Systems Ltd) |
| Argument passing - Subroutines and Functions - Mike Pope |
| Caching in on the Frames Array - Mike Pope |
| QTIPS - Fast Dynamic Array Building |
| Background Processing |
| Creating Your Own Background Processes |
| @ATTACK - @Index.Time |
| How Indexes Are Updated |
| Reader's Clinic - Functions and Subroutines |
| Argument passing - Subroutines and Functions - Mike Pope |
RevMedia FKB
| Document | V2I5A3 |
| Title | Play it Again, Cam |
| Keywords | RBASIC VIDEO.RW VSPACE PLAY GW-BASIC OUT BITOR BITAND BITNOT |
| Text | Cameron Christie who has contributed several routines to the REVMEDIA library now looks at some little used R/BASIC statements and a possible application for them I've been running R/BASIC programming courses for some time now and the most frequent question arising is not about system subroutines or WINDOW_COMMON%; instead I get "Is R/BASIC any good for writing games?" Unfortunately the short answer is: No The main differences between games and 'ordinary' programs (such as reports) are usually graphics and sound Since ARev uses a character graphics screen there's not much we can do about fast and fancy graphics VIDEO RW can be used to achieve some rudimentary animation (if you're more adventurous try dabbling WITH VSPACE!) but the bottom line is that R/BASIC is pretty much useless unless it's used to call C or Assembler routines Sound however is a more realistic proposition altogether USING standard R/BASIC the only sound available is the short monotone beep achieved by printing CHAR(7) WITH just a little knowledge of the PC's internal workings some musical theory and a few lesser used R/BASIC statements your AREV system could soon play anything FROM Sibelius to Springsteen A routine called PLAY which mimics the functionality of the GW BASIC PLAY statement will be available on the next REVMEDIA diskette In anticipation of this the theory behind the program is as follows The timer chip within the PC (the 8253 5) generates clock ticks based on a 1 193 MHz base frequency To produce an audible tone the chip's behaviour can be manipulated USING the R/BASIC OUT STATEMENT see the Technical Reference Manual for more details An initialising value of 182 is sent to port 67 followed by the low & high order bytes which are sent to port 66 (FIG 1) A general warning applies to use of the OUT statement: if your PC is not fully IBM compatible or you send bits to the wrong address then unpredictable and nasty side effects may occur be careful! Now we must go DIRECTLY to the speaker and activate it for the duration of the tone we have established (FIG 2) The speaker is controlled by the programmable peripheral interface and is accessed via port 97 If the first two bytes at this location are on then the sound will be heard ; if they are off the speaker will be deactivated To manipulate the bits within a byte we use here the BITOR and BITAND functions along WITH OUT and its opposite number INP again see the Technical Reference Manual (Those among you who like to use obscure code might like to try X = BITNOT(X) instead of X += 1; it's three times slower but you can't fault its opacity!) Finally a quick word about FIG 3 which calculates the frequency required for a given musical note An octave is actually DEFINED as a twelve note scale (including semitones) where the first note of an octave has a frequency twice that of the corresponding note in the previous octave Therefore given the frequency of one note we can work out the frequency of any other note by knowing the interval between them An alternative method would be to actually hold an array of all the required frequencies in the program; this is actually much more efficient! For more details on sound generation see The Peter Norton Programmer's Guide to the IBM PC (Microsoft Press) FIGURE 1 * For a given FREQUENCY in Hz VALUE = 1193180/FREQUENCY LOW = INT(MOD(VALUE 256)) HIGH = INT(VALUE/256) OUT 67 182 OUT 66 LOW OUT 66 HIGH FIGURE 2 * For a given DURATION in seconds * Set first 2 bits at speaker address to begin sound LAST SETTING = INP(97) NEW SETTING = BITOR(LAST SETTING 03) OUT 97 NEW SETTING * Timing Control LOOP DURATION is set elsewhere in the program * See REVMEDIA passim for documentation on the DOSTIME subroutine DOSTIME(START) LOOP DOSTIME(FINISH) UNTIL (FINISH START) > DURATION REPEAT * RESET first 2 bits at speaker address to end sound NEW SETTING = BITAND(LAST SETTING 252) OUT 97 NEW SETTING FIGURE 3 * For a given NOTE and OCTAVE (derived e g FROM a passed parameter) * calculate the FREQUENCY used by FIG 1 NOTES = "C Cs Db D Ds Eb E F Fs Gb G Gs Ab A NOTES := "As Bb B" POSITIONS = "1 2 2 3 4 4 5 6 7 7 8 9 9 10 11 11 12" CONVERT " " TO @FM IN NOTES CONVERT " " TO @FM IN POSITIONS * Note A4 is DEFINED as the root note frequency = 440 00 Hz BASE FREQUENCY = 440 * Set A4 note position within scale (4 full octaves of 12 plus 10) BASE POS = 58 LOCATE NOTE IN NOTES USING @FM SETTING POS THEN POSITION = POSITIONS OFFSET = POSITION BASE POS FREQUENCY = (BASE FREQUENCY * (2**(0FFSET/12))) END (Volume 2 Issue 5 Pages 4 5) |
Page last modified: 30/01/03