Posted: Tue Feb 21, 2012 4:42 pm
How simultaneously to lose music and a sound. For example Wav and TFC.
Sega Megadrive/Genesis development
https://gendev.spritesmind.net/forum/
How many it will occupy time?Stef wrote:Thats is not possible, no Z80 drivers support that for the moment.
I plan to add better drivers later though
Err you're right... the correct code should be equivalent to :Shiru wrote:It is rather easy if you play TFC on M68K side and samples on Z80 side - you don't need a special driver to do this. You only need to modify TFC player a bit, by stopping Z80 before writing to YM2612 registers and selecting DAC register after write and running Z80 again.
By the way, Stef, it seems that waiting for busreq with while(*ptr&0x100) is incorrect, it should be 1 instead of 0x100. Compare compiled C code with code from any old game - games always check bit 0 while compiled C code with 0x100 checks bit 8. In real programs it works on hardware either way, I guess it is because other code create a large enough delay.
Code: Select all
while(!Z80_isBusTaken());
Don't expect it *soon*, it's somewhat planned but i cannot give any date...Mixail wrote:How many it will occupy time?Stef wrote:Thats is not possible, no Z80 drivers support that for the moment.
I plan to add better drivers later though
Unfortunately SGDK library requires that minimum space for the moment.How to make, that rom (bin file) weighed not so much? At me at empty compilation it turns out 384 kb.
Code: Select all
void ym2612wr(u8 reg,u8 val,u8 bank)
{
volatile u16 *pz;
volatile u8 *pw,*pa,*pd;
pz=(u16*)Z80_HALT; //stop Z80 to prevent it from corrupting a register write
*pz=0x100;
while(*pz&1); //wait for busreq
pw=(u8*)YM2612_A0;
if(!bank)
{
pa=(u8*)YM2612_A0;
pd=(u8*)YM2612_D0;
}
else
{
pa=(u8*)YM2612_A1;
pd=(u8*)YM2612_D1;
}
while(*pw&0x80); //select register
*pa=reg;
while(*pw&0x80); //write value
*pd=val;
while(*pw&0x80); //now select DAC register back
*pa=0x2a; //so it is always selected from Z80 point of view
*pz=0; //run Z80 again
}
I realized my last modification broke my code, i mis read your initial post and just inverted my test which was incorrect.Shiru wrote: By the way, Stef, it seems that waiting for busreq with while(*ptr&0x100) is incorrect, it should be 1 instead of 0x100. Compare compiled C code with code from any old game - games always check bit 0 while compiled C code with 0x100 checks bit 8. In real programs it works on hardware either way, I guess it is because other code create a large enough delay.
Code: Select all
void VDP_drawText(const char *str, u16 x, u16 y)
{
// use A plan & high priority by default
VDP_drawTextBG(APLAN, str, textBasetile, x, y);
}
Code: Select all
//void VDP_drawText(const char *str, u16 x, u16 y);
#define VDP_drawText(str, x, y) \
VDP_drawTextBG(APLAN, str, textBasetile, x, y);
Code: Select all
extern u16 textBasetile;
If GCC was smart enough having inner calls this way would not be a problem as inlining would be automatically applied. Unfortunately GCC 3.4.6 is not inlining anything, even if you specify manually the inline keyword...sega16 wrote:I have noticed that this functionjust called another function so I commented it out and edited the header and ended up withCode: Select all
void VDP_drawText(const char *str, u16 x, u16 y) { // use A plan & high priority by default VDP_drawTextBG(APLAN, str, textBasetile, x, y); }
so that it only calls one function it worked but you have to putCode: Select all
//void VDP_drawText(const char *str, u16 x, u16 y); #define VDP_drawText(str, x, y) \ VDP_drawTextBG(APLAN, str, textBasetile, x, y);
in (if your project has it) global.h or put it in genesis.h either of those will work.Code: Select all
extern u16 textBasetile;
and at first when I was doing the makelib I got a few errors so I included vdp.h and put the extern mentioned above
The inline keyword is a hint to the compiler. You should specify the always_inline attribute if you want it to be inlined no matter what.Stef wrote:If GCC was smart enough having inner calls this way would not be a problem as inlining would be automatically applied. Unfortunately GCC 3.4.6 is not inlining anything, even if you specify manually the inline keyword...
Unfortunately inline is just *not supported* in the m68k-elf GCC 3.4.6 whatever the switch you try to specify, this is really a pity as this is the best GCC version for this target (in term of code generation).fdarkangel wrote:The inline keyword is a hint to the compiler. You should specify the always_inline attribute if you want it to be inlined no matter what.Stef wrote:If GCC was smart enough having inner calls this way would not be a problem as inlining would be automatically applied. Unfortunately GCC 3.4.6 is not inlining anything, even if you specify manually the inline keyword...
Relevant page from the GCC 3.4.6 manual.