1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2002 Ben Parnell
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 static int16 MoBuffer[2048];
23 void WriteWaveData(int32 *Buffer, int Count)
28 MoBuffer[P]=Buffer[P];
29 wsize+=fwrite(MoBuffer,1,Count<<1,soundlog);
32 static int CloseWave(void)
36 if(!soundlog) return 0;
38 fseek(soundlog,4,SEEK_SET);
39 fputc(s&0xFF,soundlog);
40 fputc((s>>8)&0xFF,soundlog);
41 fputc((s>>16)&0xFF,soundlog);
42 fputc((s>>24)&0xFF,soundlog);
44 fseek(soundlog,0x28,SEEK_SET);
46 fputc(s&0xFF,soundlog);
47 fputc((s>>8)&0xFF,soundlog);
48 fputc((s>>16)&0xFF,soundlog);
49 fputc((s>>24)&0xFF,soundlog);
55 int WriteWaveHeader(FILE *fp)
59 fseek(fp,4,SEEK_CUR); // Skip size
68 fputc(1,fp); // Monophonic
73 fputc((r>>8)&0xFF,fp);
74 fputc((r>>16)&0xFF,fp);
75 fputc((r>>24)&0xFF,fp);
78 fputc((r>>8)&0xFF,fp);
79 fputc((r>>16)&0xFF,fp);
80 fputc((r>>24)&0xFF,fp);
92 int StartSoundLog(char *str)
95 soundlog=fopen(str,"wb");
97 return WriteWaveHeader(soundlog);
101 int CreateSoundSave(void)
103 const char filter[]="MS WAVE(*.wav)\0*.wav\0";
113 memset(&ofn,0,sizeof(ofn));
114 ofn.lStructSize=sizeof(ofn);
115 ofn.hInstance=fceu_hInstance;
116 ofn.lpstrTitle="Log Sound As...";
117 ofn.lpstrFilter=filter;
121 ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
122 if(GetSaveFileName(&ofn))
123 return StartSoundLog(nameo);