RUSH #01
29 мая 1999 |
|
Spectrum programming - Sound effects for a music processor and combine with the main melody.
(C) 1997-99, A. Bezugly (Ticklish Jim / BIS / Rush) SOUND EFFECTS FOR MUSIC PROCESSOR AND MATCHING With the main melody So muzprotsessor ... Gone are the times when people are satisfied with unassuming bibikanyami dynamics SPECCY during the game. Now anyone who wrote his play necessarily involves in it music. Naturally, for AY'a. Someone is coming further supports LPT COVOX, SOUNDRIVE, GENERAL SOUND ... Someone music is better, someone worse, but it's not it - now the program without music support for AY causes at as a surprise. However, listening music, but sometimes it is not enough. So want to hear the shuffling of feet of the hero or dripping water, for example, and you hear only some overextended motif (well even if music can be turned off). But suddenly you still hear the rustle of wind and cherished ... Notice that prevails around the dead silence, which can not revive even your steps. There inevitably recall unprecedented cycle of games DIZZY, where through the music clearly punched sounds ... on the dynamics of the beeper. In general, where Whatever else - everywhere wedge. Yes, sometimes all the same there are programs in which the sound effects are displayed in parallel with the music, but such examples are quite small. I hope this article helps someone when writing their own toys. I do not claim to truth in the last instance, moreover, convinced that someone decided / solve this problem more elegantly me but still ... While working on "CSC: Deja Vu" in some point the question arose accompanied by music games. Remembering public reaction to the absence of AY-music CSC-1 (by the way, there is already version for cars with 128K RAM. And the music plays in menus and during gameplay.) was unanimously agreed to voice a new game. After a while it became clear that music just is not enough. Panda vystrenko concocted a dozen effects and ... Work has stalled. Nobody knew how to combine music and effects. All attempts ended in failure - the hissing, wheezing, and nothing more. Even working with specially written dual music, nothing gave. Although surprised nothing: Panda writes music, but only as I generally far from the case man. One way or another, but the question was about the effects of postponed indefinitely. And generally, somewhere in late May '97go work the game ended. The reason for that was my own and draw more glitches. Somewhere in the middle of autumn 1997, I traveled to Sevastopol, where he met with Dismaster'om and Squizer'om (not counting gang SMASH'evtsev). At that time, I again started thinking about the continuation of work on CSC (at that time there was a program AVTOMASKI, but my computer is broken) why did not fail to take advantage of case and agreed with Dismaster'om What about the special the Player for music and special effects. Arranged for the left ... Passed three months ... Dis'a probably everything forgot (I, too, is good, and not bothered to write a letter or Squizer'u, nor Dis'e), and the cry of Mighty Hacker none and did not think to respond. In short, wait for assistance was not from anyone, and that's himself had come to grips with this problem. Below is an example of a small program that I have supplied exhaustive, in my opinion, comments. I think, understand that the Why not make much effort. Yes, until do not forget - my program is designed for something that the sound effects are derived via 'B', a two-channel music. It is possible, Of course, removing the last restriction, but then have to sacrifice cleanliness sound effects and live with overlay, which will inevitably arise. But everyone makes their own way, so that See for yourself. Literature, which I used until the deal with the work AY'ka not numerous: ZX-REVIEW # 5'95 and Unforgettable "ZX-SPECTRUM and TR-DOS for users and programmers, "A. Larchenko and Rodionova. In the beginning you need to know number of notes (I'm no expert, so I admit that some of the terms will be a misnomer, however, important is the essence) in the special effects. To do this, I personally use the following primitive applets in BASIC: 10 RANDOMIZE USR 49152: LET A = 65533: LET B = 0: REM sound effect is written ProTracker'e in and swapped out to disk together with the player at 49152 20 RANDOMIZE USR 49158: LET B = B +1: OUT A, 9: PRINT AT 0,0; "Volume Channel B = "; IN A;" "';" Number of the current notes = "; B;" ": REM This line readout is called volume information for Channel B, the end of the sound says 0 on the screen and silence in dynamics, the number in a long LEN, on kotoy it will be lower. 1930 PAUSE 0: IF INKEY $ <> "q" AND INKEY $ <> "Q" THEN GOTO 1920: REM This line is necessary for stepping effects. Calculating the length (number of B) can proceed to the procedures in assembler. Load the file FX (can not be shipped, if memory computer has not been cleaned after use BASIC program) with the desired effect and consistently perform routines MAKE and PACKER. The first essential for creation of a memory array data muzprotsessora registers, and the second - for little optimization of the array (The optimization is incomplete, since it is possible to win another byte of each note). After this, ready reserve unit Data from the address pointed to by variable SOUND (40000), length LEN * 4 (Packed, though, as said above, possible and LEN * 3). Now we can proceed directly to the demonstration. As set the music to interrupt, I think, no one explained the do not. But before initializing the player must make any minor changes. For This should throw a block on TO_PLAYER address equal adres_zagruzki_muzyki 1351 (For player of the PT2.1). Block length 97 bytes. Someone may wonder: "Why completely remove the processing of a channel from the player, if there so empty? " In response, I can only offer porobovat not to amend the player - listen and compare. Okay, to solve this. Now a couple of words about the program, responsible for playback effects. I did so, sound to be issued on AY pressing FIRE key at Kempston (incidentally, that quit the program, you should click simultaneously UP, DOWN, LEFT, RIGHT on the same Kempston). Of course, the game you have to add a procedure for choosing the right sound, etc. etc. But in this case It does not require, therefore, assume that There is only one SFX, which must be heard when you press certain keys and not interrupted until until you hear the last note. Quite naturally, SFX note should sound after the note composition, ie, Once an interrupt. In general, see the comments as proper description of my program come to an end. (C) 1998, T.J. MUS ORG 49152 ;. INCBIN MUSIC ORG 40000 ;. INCBIN fx2 ; PACK LENGT = 136 bytes EFFECT ORG 49152 ;. INCBIN FX ; PT-module WITH SFX FXBUF EQU 32768 ORG 25000 JR BEGIN ; PLAY MUSIC 'SFX CALL MAKE ; MAKE SOUND FX ; WORK WITH FILE AS LOADED AT ; "EFFECT"-ADRESS JP PACKER ; PACK SOUND FX BEGIN DI LD HL, TO_PLAYER LD DE, MUS +1351 LD BC, 97 LDIR ; Made changes to the player tunes LD A, # 25 LD I, A IM 2 LD A, 195 LD HL, IMMER LD (23670), A LD (23671), HL , Included the interruption of the 2nd kind CALL MUS ; Initialize player EI HALT M1 XOR A IN A, (31) CP 1915 JR Z, EXIT ; When pressing 4 keys Kempston, , Then go for the procedure completed; sheniya program CP 1916 JR NZ, M1 And if no key is pressed FIRE , Then go to the top of the loop LD A, 1 LD (SND_PR), A , Chose a number of SFX K1 CALL NASTR ; Specify parameters for a given SFX , (Address of an array of data and the length of SFX) LD A, # 3A LD (K1), A , Blocked a challenge to the update procedure ; Options with a view ; To finish the SFX to end before ; Will turn next SFX , (Of course, you can lock ; Poizyaschnee, but, I repeat, in this case , It does not matter, so I was mouth; raivaet transformation CALL NASTR in ; LD A, (NASTR)) and went on to; chalo cycle. JR M1 ; Procedure for stopping work ; Demos. ; Before completing set ; Interrupt the 1st kind switch off; differs music player, ; Jamming channel SFX and return to ; The main program. EXIT DI LD A, # 3F LD I, A IM 1 CALL MUS; MUSIC OFF LD BC, 65533 LD A, 9 OUT (C), A XOR A LD B, # BF; CHANNEL 'B' OFF OUT (C), A EI RET , Procedure interrupt handling. I hope ; Do not need to explain anything IMMER DI PUSH HL PUSH DE PUSH BC PUSH AF EX AF, AF ' PUSH AF EXX PUSH HL PUSH DE PUSH BC EXX PUSH IX PUSH IY CALL MUS +6 ; Calling player SFX CALL PLR POP IY POP IX EXX POP BC POP DE POP HL EXX POP AF EX AF, AF ' POP AF POP BC POP DE POP HL EI RET SOUND DEFW 40000 SND_PR DEFB 0 LEN DEFB 8; LENGT OF SFX (/ 4) ; PLAYER FOR SOUND FXS ; WORK ONLY WITH CHANNEL 'B'!!! ; Player for SFX. PLR LD A, (SND_PR) OR A RET Z Return, if the address is SND_PR ; 0, ie No SFX no ; Selected ADR_SND LD HL, 40000 ; In HL start address SFX ; (Set p / n NASTR) LD DE, # BFFF LD A, 80 ; In A length of SFX (also set p / n ; NASTR) X3 EX AF, AF ' , Followed by the output data registers ; Coprocessor 2,3,6,7 and 9; , And the data for 3 and 9 are decompressed ; One byte LD C, 253 LD B, E LD A, 2 ; SELECT CHANNEL 'B' OUT (C), A LD A, (HL) LD B, D OUT (C), A INC HL LD A, 6 LD B, E OUT (C), A LD A, (HL) LD B, D OUT (C), A INC HL LD A, 7 LD B, E OUT (C), A IN A, (C) ; OLD CONSEQUENCE OR (HL) ; ADD NEW 'OLD ; These two lines were necessary in order ; To our SFX are not silenced And the remaining channels are used ; To display the main melody LD B, D OUT (C), A INC HL LD A, 3; SEL. CH. 'B' LD B, E OUT (C), A LD A, (HL) RRA RRA RRA RRA AND # 0F ; Value for R3 remained in the leading ; Polubayte LD B, D OUT (C), A LD A, 9 ; VOLUME OF CH 'B' LD B, E OUT (C), A LD A, (HL) AND # 0F ; WITHOUT 4th BIT! (Envelope) ; Value for R9 preserved ; Junior polubayte LD B, D OUT (C), A INC HL EX AF, AF ' DEC A LD (SND_PR), A ; Until SFX does not sound ; Fully variable will not be ; Reset. JR NZ, HLP ; ONLY FOR INTERRUPTS ; We correct address value and the length of SFX ; For the next note, , Which will be played next ; Interruption LD A, # CD LD (K1), A ; After playing SFX necessary ; Restore procedure call selection parameters, the parameters for the next SFX (CALL NASTR) RET NASTR LD A, (LEN) LD HL, (SOUND) HLP LD (X3-1), A LD (ADR_SND +1), HL RET ; Table TABL contains a list of registers ; AY, used my software. ; Because for the effects we have set aside ; Only channel B, then we need only ; Registers 2,3 (pure and crude tone , Respectively), 6 (Noise), 7 (mixer) And 9 (the volume of B). ; I have not used regostry 11.12 and 13 ; (Frequency and type of envelope) , In order to save memory, but who wish ; That will not be difficult to alter my ; Program to your liking (although, as ; Practice shows that when creating music. ; Special effects without the envelope can be completely ; Do), do not forget that this is ; Just an elementary example of working with ; Sound. ; This table is used only ; Procedures and MAKE PACK. TABL DEFB 2,6,7,3,9 DEFB 255 ; Sub-create an array of data. MAKE CALL EFFECT ; Initialize player LD IX, FXBUF ; In IX enters buffer address LD A, (LEN) LD B, A ; In B - number of notes M11 PUSH BC PUSH IX CALL EFFECT +6 ; Lost note POP IX LD HL, TABL M3 LD BC, 65533 LD A, (HL) CP 255 JR Z, M2 OUT (C), A IN A, (C) , Read from the desired register LD (IX +0), A ; Brought into the buffer INC HL INC IX JR M3 M2 POP BC DJNZ M11; repeat CALL EFFECT ; Disconnect the player RET ; Sub-packages of the array data PACKER LD IX, FXBUF ; In IX buffer address LD HL, (SOUND) ; In HL the address from which will be considered; pologatsya packaged unit LD A, (LEN) LD B, A ; In B - number of notes L1 LD A, (IX +0) LD (HL), A; R2 INC HL LD A, (IX +1) LD (HL), A; R6 INC HL LD A, (IX +2) LD (HL), A; R7 INC HL LD A, (IX +3) AND # 0F RLA RLA RLA RLA LD C, A LD A, (IX +4) AND # 0F OR C LD (HL), A; R3 + R9 INC HL ; 5 bytes instead of one note, we got 4. ; Full length final block is LEN * 4. ; If you use an envelope, then ; Have to give up ; Combining R3 and R9 (as in the case 9m ; Will need to consider 4th bit , Although it will be possible to unite R3 and R13 - , Both of ; Used only the lower 4 bits.) LD DE, 5 ADD IX, DE DJNZ L1; repeat cycle RET ; CHANGES FOR ProTracker2.1 PLAYER ; ADRES = LOAD_ADR +1351 ; (For PT2.1 by Golden Disk) ; = LOAD_ADR +1857 ; (For PT2.4 by GD 'Fantom Family) ; LENGT = 97 bytes ; CHANNEL 'B' NOT USED!!! IT'S ONLY FOR SOUND FXS!!! ; New unit for the player TO_PLAYER LD B, D OUT (C), A; R13 LD B, E OUTD DEC A LD B, D OUT (C), A; R12 LD B, E OUTD DEC A LD B, D OUT (C), A; R11 LD B, E OUTD DEC A LD B, D OUT (C), A; R10 ; (VOLUME 'C') LD B, E OUTD DEC A; R9 ; (VOLUME 'B')!!! DEC HL ; Previous two lines will ensure ; That no data from this ; Composition will not be issued on ; Channel B. DEC A LD B, D OUT (C), A; R8 ; (VOLUME 'A') LD B, E OUTD DEC A LD B, D OUT (C), A; R7 ; (MIXER!!!) LD B, E ; And here we are doing so ; Our own parameters for ; Channel B found their way to the listener ; (Zero out bits 1 and 4, ie , Authorize the issuance of tone and noise ; Channel B) LD A, (HL) AND # 2D;!!! ; (FOR 'B') LD (HL), A OUTD LD A, 6 LD B, D OUT (C), A; R6 LD B, E OUTD DEC A LD B, D OUT (C), A; R5 LD B, E OUTD DEC A LD B, D OUT (C), A; R4 LD B, E OUTD ; We correct battery so , So it was 1. ; This is necessary in order ; To circumvent the issue of data, preamplifier; It refers to an executable composition ; Registers clean and rough, for any tone of the channel B. SUB 3 DEC HL; R3 ; (FOR 'B'!!!) DEC HL; R2 LD B, D OUT (C), A; R1 LD B, E OUTD DEC A LD B, D OUT (C), A; R0 LD B, E OUTD DEFS 11 ; The last line is necessary for ; Add the block to 97 bytes. For the new version of the editor PT3.31 by Golden Disk changes are made at LOAD_ADR +1825: AND 45 ; Disable channel "B" OUT (C), A INC L LD B, D OUT (C), L LD B, E OUTI INC L DEFS 3 I think that will be easy to understand. Only note that this method of combining effetov music and in my opinion is easy because uses the traditional player and a small sound issue protsedurka in the channel. The hardest part - directly to the creation of sound. More precisely, create something just simply - in the same editor, but relatively difficult to then receive data. Maybe just for me I do not argue. Yeah, write to someone program from a human, I would be very happy, but for want of a better ... Perhaps someone like a soft, but I do not met. Basically, as I understand it, the authors write either for their own players melodies and effects (for example, have done so guys BITMUNCHERS in his toy KLIDEMINER), or wildly distorted by standard (demo version of MARIO BROS OMEGA HACKERS). I do not know how Glory comes Mednonogov - was not asked to learn. In any case, what would I have told, as have so far not seen anywhere else and article on this topic. Again, either everyone knows everything, or everything to everyone do not care. This material in its time overtaken the same fate as the article about AVTOMASKE. I hope that even now, after two years, it is someone will read and apply on praktike.
Other articles:
Similar articles:
В этот день... 21 November