Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - BBC Micro sound logging

Reply to topic
Author Message
Dave
  • Guest
Reply with quote
BBC Micro sound logging
Post Posted: Sun Jul 14, 2002 6:47 pm

I wrote some code for BeebEm to log BBC Micro sound. The WinAMP plugin actually sounds better than the emulator itself. Speech sounds really good as well.
Sent it to the authors so fingers crossed the next version of BeebEm will log to VGM.

Here's the list of changes:
Added this to main.cpp
VgmStart("bbcsound.vgm");
do
{
...
}
VgmStop();

this to 6502core.cpp:
Cycles=CyclesTable[CurrentInstruction];
CycleCount+=Cycles; // <---- this line
while (CycleCount>0) { VgmWait++; CycleCount-=42; } // <---- and this line

this to beebsound.h:
int VgmStart(char *Filename);
int VgmStop();
extern int VgmWait;

and this to beebsound.cpp:
-------------------------------------------------------------------
static FILE *VgmFile=NULL;
int VgmWait=0;
static unsigned int WaitTotal=0;

int VgmStart(char *Filename)
{
unsigned char Head[0x40];
memset(Head,0,sizeof(Head));

VgmFile=fopen(Filename,"wb");
if (VgmFile==NULL) return 1;

memcpy(Head,"Vgm ",4);
*(int *)(Head+0x8)=0x101; // VGM version (1.01)
*(int *)(Head+0xc)=4000000; // PSG chip speed

fwrite(Head,1,sizeof(Head),VgmFile);

return 0;
}

static int VgmWrite(int v)
{
unsigned char Wait[3]={0x61,0,0};
unsigned char Cmd[2]={0x50,0};
int w=0;
if (VgmFile==NULL) return 1;

// Flush wait:
while (VgmWait>0)
{
w=VgmWait; if (w>0xffff) w=0xffff;
*(unsigned short *)(Wait+1)=w;
fwrite(Wait,1,sizeof(Wait),VgmFile);
WaitTotal+=w;

VgmWait-=w;
}

Cmd[1]=v;
fwrite(Cmd,1,sizeof(Cmd),VgmFile);
return 0;
}


int VgmStop()
{
unsigned char Cmd[1]={0x66};
unsigned int EndPos=0;

if (VgmFile==NULL) return 1;

// Write end of sound data
fwrite(Cmd,1,sizeof(Cmd),VgmFile);

// Write offset to end of VGM file
EndPos=ftell(VgmFile)-4;
fseek(VgmFile,0x04,SEEK_SET);
fwrite(&EndPos,1,4,VgmFile);

// Write total wait times in VGM file
fseek(VgmFile,0x18,SEEK_SET);
fwrite(&WaitTotal,1,4,VgmFile);

fclose(VgmFile); VgmFile=NULL;
return 0;
}
-------------------------------------------------------------------
 
Reply to topic



Back to the top of this page

Back to SMS Power!