New XGM driver !
Moderator: Stef
Hi,
Here you can listen a tune for Antarex with the XGM driver captured from the stereo output of a PAL Mega Drive I with no filters, equalization...
https://soundcloud.com/david-alt-sanche ... -level-1-1
The setup for this music is:
5 FM + 1 PCM for drums (1 snare, 1 bassdrum and 2 toms @8Khz because we were using the VGM driver) + PSG Noise for the hat.
VGM 1.60 made with Deflemask.
Turn volume to the max and hope you like it.
I'm making some tests with the other PCM channels for effects. Any news i will keep you informed.
Of course, thank you very much Stef for this driver. It will suppose a new level in the sound of homebrew games
Here you can listen a tune for Antarex with the XGM driver captured from the stereo output of a PAL Mega Drive I with no filters, equalization...
https://soundcloud.com/david-alt-sanche ... -level-1-1
The setup for this music is:
5 FM + 1 PCM for drums (1 snare, 1 bassdrum and 2 toms @8Khz because we were using the VGM driver) + PSG Noise for the hat.
VGM 1.60 made with Deflemask.
Turn volume to the max and hope you like it.
I'm making some tests with the other PCM channels for effects. Any news i will keep you informed.
Of course, thank you very much Stef for this driver. It will suppose a new level in the sound of homebrew games

-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Hi Davidian,
Thanks for the preview ! A very nice tune which really suit for that type of game, well done ! I'm happy to hear you successfully moved to the XGM driver, it's good to see it used
I still have some stuff to fix or improve (pause / stop music command, auto enable/disable DAC mode for FM5).
Another good news is that i am discussing with Delek so he can add support for the XGM driver in DefleMask editor (and so have access to 4 PCM at 14 Khz for music). It will still export in VGM (with 4 PCM channels) but my next xgmtool version will be able to translate them in XGM format.
Thanks for the preview ! A very nice tune which really suit for that type of game, well done ! I'm happy to hear you successfully moved to the XGM driver, it's good to see it used

I still have some stuff to fix or improve (pause / stop music command, auto enable/disable DAC mode for FM5).
Another good news is that i am discussing with Delek so he can add support for the XGM driver in DefleMask editor (and so have access to 4 PCM at 14 Khz for music). It will still export in VGM (with 4 PCM channels) but my next xgmtool version will be able to translate them in XGM format.
-
- Very interested
- Posts: 89
- Joined: Mon Feb 24, 2014 6:04 pm
- Location: Kapuskasing, Ontario, Canada
- Contact:
Stef, great work on this driver!
I've been reading the Z80 source code and I have a question. I reached line 373 (in here) and I noticed something odd:
ADD and ADC are supposed to take two operands as far as I know 
http://www.villehelin.com/mnemonics_z80_a.txt
Is this intentional or is there some other ADD mnemonic which I've never encountered using WLADX?
I've been reading the Z80 source code and I have a question. I reached line 373 (in here) and I noticed something odd:
Code: Select all
; readMixAndUnsign
; ----------------
; ? -> HL -> point to the sample source (ROM)
; ? -> DE -> point to write buffer
; $80 -> B
;
; read 1 sample and mix it with output buffer, then unsign it
; = 40 (+11 when overflow)
macro readMixAndUnsign
LD A, (DE) ; read value in write buf ' 7 |
ADD (HL) ; mix with source sample ' 7+1 | (25)
JP PO, .ok ; check overflow ' 10 |
LD A, B ; fix overflow ' 4 |
ADC $FF ; A = $7F/$80 ' 7 | +11
.ok
ADD B ; unsign ' 4 |
LD (DE), A ; write sample in buffer ' 7 | 19 (44)
INC E ; ' 4 |
INC L ; next ' 4 |
endm ; ' 44 (+11)

http://www.villehelin.com/mnemonics_z80_a.txt
Is this intentional or is there some other ADD mnemonic which I've never encountered using WLADX?
What does db stand for? Well that's an excellent question...
http://www.db-electronics.ca
http://www.db-electronics.ca
-
- Very interested
- Posts: 2993
- Joined: Fri Aug 17, 2007 9:33 pm
-
- Very interested
- Posts: 89
- Joined: Mon Feb 24, 2014 6:04 pm
- Location: Kapuskasing, Ontario, Canada
- Contact:
Well I learned something today! WLA DX doesn't let me do that!Chilly Willy wrote:Most z80 assemblers assume A is the target when left off. In fact, some z80 assembler books don't even show A as the target for opcodes targeting A - it's just assumed.
What does db stand for? Well that's an excellent question...
http://www.db-electronics.ca
http://www.db-electronics.ca
Hey. Thanks a bunch for this new driver its awesome! I can play music without using a load of memory and easily play sound effects too!
I just have a quick question, if I want to create some sort music visualiser do you know how I can access data on the sound channels?
e.g is it playing and at what volume. This would help me loads with the effect I'm trying to achieve in my game.
Thanks
I just have a quick question, if I want to create some sort music visualiser do you know how I can access data on the sound channels?
e.g is it playing and at what volume. This would help me loads with the effect I'm trying to achieve in my game.
Thanks

-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Thanks for the kind comment 
Well unfortunately you don't have much of the sound data state in the XGM driver mainly because of the small amount of free Z80 memory (less than 256 bytes).
You have states of the D1R and RR ym2612 registers and also the state of DAC enabled register but this one is not really useful.
Then you have PSG envelop state and the PCM buffer.
Here is the address for different meaningful informations for you:
XGM music playing state: 0xA00102 bit 6
PCM channel playing state: 0xA00102 bit 0 to bit 3 (channel 0 to channel 3)
D1L / RR registers state: 0xA00144-0xA0015B (6 channels * 4 operators)
PSG envelop: 0xA0015C-0xA0015F (4 channels)
DAC enabled: 0xA00160 (bit 7)
Circular PCM buffer: 0xA01800-0xA01BFF
You can find the current read PCM segment at 0xA00140.
Note that the address is stored as byte so you only have bit 8 and bit 9 as the lower bits are always 0.
For instance if you read 0 from 0xA00140 then current PCM read buffer is 0xA01800, if you read 3 then current read PCM buffer is 0xA01B00...
I think that's all for music data / state

Well unfortunately you don't have much of the sound data state in the XGM driver mainly because of the small amount of free Z80 memory (less than 256 bytes).
You have states of the D1R and RR ym2612 registers and also the state of DAC enabled register but this one is not really useful.
Then you have PSG envelop state and the PCM buffer.
Here is the address for different meaningful informations for you:
XGM music playing state: 0xA00102 bit 6
PCM channel playing state: 0xA00102 bit 0 to bit 3 (channel 0 to channel 3)
D1L / RR registers state: 0xA00144-0xA0015B (6 channels * 4 operators)
PSG envelop: 0xA0015C-0xA0015F (4 channels)
DAC enabled: 0xA00160 (bit 7)
Circular PCM buffer: 0xA01800-0xA01BFF
You can find the current read PCM segment at 0xA00140.
Note that the address is stored as byte so you only have bit 8 and bit 9 as the lower bits are always 0.
For instance if you read 0 from 0xA00140 then current PCM read buffer is 0xA01800, if you read 3 then current read PCM buffer is 0xA01B00...
I think that's all for music data / state

Can you tell us the use of priority for PCM ?
Does it mean a PCM with priority 1 will be played while a priority 2 pcm is muted ? or priority 2 will be played after priority 1 ?
and what about ID ?
Does it mean we could pre-load PCMs and then call their ID for playing ?
also I see on SGDK sound.c you use prio 0, id 0 to silent PCM
does it mean we should avoid these values ?
last one, can you confirm PCM is 8bit 14Khz ?
lot of questions, no ?
Does it mean a PCM with priority 1 will be played while a priority 2 pcm is muted ? or priority 2 will be played after priority 1 ?
and what about ID ?
Does it mean we could pre-load PCMs and then call their ID for playing ?
also I see on SGDK sound.c you use prio 0, id 0 to silent PCM
does it mean we should avoid these values ?
last one, can you confirm PCM is 8bit 14Khz ?
lot of questions, no ?

-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Higher priority has priority mean priority 2 will play over priority 1 but not the contraryKanedaFr wrote:Can you tell us the use of priority for PCM ?
Does it mean a PCM with priority 1 will be played while a priority 2 pcm is muted ? or priority 2 will be played after priority 1 ?

Sort of, actually XGM driver internally assign id to PCM sample.and what about ID ?
Does it mean we could pre-load PCMs and then call their ID for playing ?
0 is reserved (used to turn PCM off)
1-63 is reserved for music
64-255 is reserved for SFX
So for instance when you want to play SFX you can do this :
Code: Select all
// set sample id (>= 64 for SFX else you can override music PCM)
SND_setPCM_XGM(66, loop1_14k, sizeof(loop1_14k));
// then play sample at priority 10 on channel 4
SND_startPlayPCM_XGM(66, 10, SOUND_PCM_CH4);
Code: Select all
SND_setPCM_XGM(id, sample, sizeof(sample));
Code: Select all
SND_startPlayPCM_XGM(id, priority, channel);
Note that the sound sample example contains code example for the XGM driver use :
https://github.com/Stephane-D/SGDK/blob ... src/main.c
Exactly, id #0 is used to silent PCM channelalso I see on SGDK sound.c you use prio 0, id 0 to silent PCM
does it mean we should avoid these values ?

8 bits signed at 14 Khz, but i would say that you don't really care, if you declare your sample in a .res resource file then you can just use a WAV file to play through the XGM driver, just declare it this way :last one, can you confirm PCM is 8bit 14Khz ?
Code: Select all
WAV <name> <file> [driver [outrate]]
Here you can find the description about .res file :
https://github.com/Stephane-D/SGDK/blob ... escomp.txt
And here the description of the XGM driver & format :
https://sgdk.googlecode.com/svn/trunk/bin/xgm.txt
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Having 10 or 100 SFX does not eat more "memory", SFX are just plain PCM and so consume ROM. As soon you have them fitting in your ROM, you can play them freely with the XGM driver.
You actually have 63 PCM id reserved for music and 192 for SFX... I think that is more than enough (and you can change id allocation without any restriction)
You can indeed do all your SND_setPCM_XGM(..) calls at beginning then just use SND_startPlayPCM_XGM(..)
You actually have 63 PCM id reserved for music and 192 for SFX... I think that is more than enough (and you can change id allocation without any restriction)

You can indeed do all your SND_setPCM_XGM(..) calls at beginning then just use SND_startPlayPCM_XGM(..)