Schrijver
| PLAY command in BASIC
|
Imanok msx addict Berichten: 283 | Geplaatst: 12 April 2006, 09:40   |
When you use the PLAY command in basic, it takes some time since you execute it and the music starts to play. It takes some time too until you can see the basic prompt again.
Is there any way to reduce/eliminate that times??... somehow storing the data in the buffer before executing or something like that...
 |
|
diederick76 msx user Berichten: 63 | Geplaatst: 12 April 2006, 13:53   |
Are you using an emulator? I haven't programmed any basic in ten or so years, but I remember distinctly that basic passed the play data to the sound chip and returned control immediately back to the user. That way it was possible to make games in basic with background music.
So unless you mean with "some time" something that can only be used in assembly, I don't see how you can have that problem.
|
|
Edwin msx professional Berichten: 620 | Geplaatst: 12 April 2006, 14:16   |
IIRC, it does, but the play buffer only has a limited size. If you exceed that, it will wait until the remaining data fits the buffer. So it appears you're using large strings in your play commands. The start delay probably has to do with parsing large play strings as well.
|
|
BiFi msx guru Berichten: 3142 | Geplaatst: 12 April 2006, 14:20   |
How the PLAY command works... It's split up into two routines: - the PLAY parser
- the PLAY routine on the interrupt
The PLAY parser writes the data to the PLAY queue area's. When the queue is full the parser waits until there's free space in the queue again... Then it will resume parsing. The PLAY routine on the interrupt parses the PLAY queue and writes the data to the PSG.
The PLAY queue area is 128 bytes for each channel. |
|
norakomi msx professional Berichten: 861 | Geplaatst: 12 April 2006, 14:30   |
hmmmm,
I never had that problem either.
Hey, it is possible to play music in basic, (almost) independant of you program.
You can use an on interval gosub to a linenumber in your program where the music is being played....
I dont know if this is any usefull for you, but i was thinking of something like:
10 on interval gosub 100
20 interval on 'I have no idea if this is correctly programmed, anyone?
30 ?"In this loop, music is played"
40 goto 30
100 play"abababababab"
110 return
|
|
NYYRIKKI msx master Berichten: 1510 | Geplaatst: 12 April 2006, 19:33   |
norakomi: No that program will not work... you must specify the interval like this:
10 on interval=50 gosub 100 ' One time each second in 50Hz display mode.
The problem here is, that you should know exactly how long your play buffer is used to put just enough to almost fill it, but not too litle so that music play will stop in between the interrupts. You can also use PLAY(N) function to test if there is actually something in the buffer, but that does not remove the problem. Although this is possible, it is so hard, that implementing custom replay routine is STRONGLY suggested.
If you are interested about PSG music, check out PT3 replayer routine. For FM-PAC and MSX-AUDIO MoonBlaster is quite a nice choice. For MoonBlaster there is even ready made BASIC extention delivered with the program, that adds CALL commands to basic for loading and playing the backround music.
|
|
flyguille msx master Berichten: 1202 | Geplaatst: 12 April 2006, 20:08   |
what I did in some games
5 PC=0:SN=0 ' SN = song number
10 on interval gosub 1010
1000 ' PLAY routine
1010 if play(0) then return
1020 on PC gosub 1100,1110,1120,1130,1140,1150,1160,1170,1180,1190 ....
1030 PC=((PC+1) mod 10)+SN*10
1040 Return
1100 play "frst part"
1105 return
1110 play "second part"
1115 return
1120 play "part 3"
1125 return
...
and you control the play with activating or deactivating the interval. But that can slowdown the playgame routine... so, I realy had just inserted in the playgame routine a IF PLAY(0)=0 then Gosub 1010 (IIRC)
anyway just the parse data to the buffer, makes freezes in the animation of the game, because that is advisable to use a assembler routine for the play and control that with pokes. Because a routine+sounddata module has all already parsed and not needs to parse strings as to copy that to buffer, the play cursor can to be pointing to that BIN instead in the normal BASIC buffer.
|
|
Imanok msx addict Berichten: 283 | Geplaatst: 12 April 2006, 20:36   |
Quote:
| If you are interested about PSG music, check out PT3 replayer routine. For FM-PAC and MSX-AUDIO MoonBlaster is quite a nice choice. For MoonBlaster there is even ready made BASIC extention delivered with the program, that adds CALL commands to basic for loading and playing the backround music.
|
In my other games I made use of the Moonblaster replayer included in Nestorbasic, but now I'm doing some tests making a basic MSX1 rom. Due to the lack of free space, I thought about making a few little tunes with PLAY & SOUND (instead of using the PT3 replayer), but I don't like that delaying issues...
Btw, I'm not using an emulator, but a real MSX. |
|
NYYRIKKI msx master Berichten: 1510 | Geplaatst: 15 April 2006, 23:07   |
I did some testing... maybe something like this could work:
10 on interval=25 gosub 100
20 interval on
30 ' Example main code
40 for i=0 to 100:next:p=p+1:?p
50 goto 40
100 X=peek(&hf959)-peek(&hf960): if X>30 or X<0 then return
110 'Put advanced play routine here (look flyguille example)
120 play "CCDECEDD"
130 RETURN
|
|
|
|
|