how can i do music on megadrive?

For anything related to sound (YM2612, PSG, Z80, PCM...)

Moderator: BigEvilCorporation

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef »

TmEE co.(TM) wrote:
Stef wrote:Sorry i was really long, here's the link :

Z80 basic driver for sample play (source)

The code is commented here and there, hope you understand it ;)
have fun :)
Your code is really understandable, your coding style is exactly like mine :)
:)
TmEE co.(TM)
Very interested
Posts: 2452
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) »

Do you change bank for every sample ?
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef »

TmEE co.(TM) wrote:Do you change bank for every sample ?
Nope, i'm testing for sample address bit 15 change.
If changed then i set bank else i don't ;)
TmEE co.(TM)
Very interested
Posts: 2452
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) »

No No, I meant in 2ch mixing.

Do you know any good doc on z80, I saw some things in your code which I thought cannot be done on z80 that way.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef »

TmEE co.(TM) wrote:No No, I meant in 2ch mixing.

Do you know any good doc on z80, I saw some things in your code which I thought cannot be done on z80 that way.
In the 2ch mixing, of course i do it at each sample, you need to do it since your sample can be located in different bank...

I've a very nice Z80 document, i used it a lot to code my CZ80 core, specially to implement undocumented opcodes and flags.
I guess you're talking about the XH and YH use in my code ? i think i'm using an unofficial opcode but they are supported on all Z80 type CPU so no problems ;)
Last edited by Stef on Fri Feb 16, 2007 8:38 am, edited 1 time in total.
TmEE co.(TM)
Very interested
Posts: 2452
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) »

I knew about XH, XL... but I saw LD DE, (ASDFGH) (<-reg maybe incorrect), I thought that you can only use A or HL (and X, Y) for memory stuff
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef »

TmEE co.(TM) wrote:I knew about XH, XL... but I saw LD DE, (ASDFGH) (<-reg maybe incorrect), I thought that you can only use A or HL (and X, Y) for memory stuff
I know AS assembler is sometime taking shorter in mnemonic.
For instance it accept LD BC, DE even if that's not a valid mnemonic (internally it does LD B, D and LD C, E).

but about LD DE, (var)
actually this is a valid instruction (taking 20 cycles where LD HL, (var) takes only 16 cycles)
TmEE co.(TM)
Very interested
Posts: 2452
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) »

OK, now I see, I prefer to use faster stuff
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef »

TmEE co.(TM) wrote:OK, now I see, I prefer to use faster stuff
This code is used at init time, just to keep the sample address in DE register :)
By the way, you can freely modify the source for your needs. All improvements are welcome also :)
TmEE co.(TM)
Very interested
Posts: 2452
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) »

I think I'm going to use some things, you know more advanced stuff than I. I looked at your code, and I think, I could not make it faster.
Is usage of X and Y slower than HL ?
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef »

TmEE co.(TM) wrote:I think I'm going to use some things, you know more advanced stuff than I. I looked at your code, and I think, I could not make it faster.
Is usage of X and Y slower than HL ?
I think there is always way to improve it, not necessary on speed, but maybe on feature as loop playing :p
Using X and Y permit me to avoid a memory access so i gain some cycles here yeah ;)
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef »

I finally rewrote my 2 samples player z80 driver. I improved it : we can now stop a sample currently played :p Unfortunatly i definitly can't touch 16 Khz playback, i'm stuck at something close to ~14 Khz.

You can get it in the updated mini devkit :
http://www.spritesmind.net/_GenDev/foru ... c.php?t=14
TmEE co.(TM)
Very interested
Posts: 2452
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) »

I'll check it out ... on monday, I have dial up at home and downloading 1MB is pain but to talk about 13MB !
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal »

kick ass !!! :) thanks !!! can i use the driver only in my game project ?
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef »

Pascal wrote:kick ass !!! :) thanks !!! can i use the driver only in my game project ?
You can use anything as you want of course :) I put it in the mini devkit because it's common to have it here but you can use freely all part as you want (and then include some part of source in your project).
Post Reply