Checking whether the file exists before wiping it out is left up to the reader..err...I mean, the driver code, if it feels so inclined(I don't feel so). */
| 16 | so). |
| 17 | */ |
| 18 | void FCEU_WriteWaveData(int32 *Buffer, int Count) |
| 19 | { |
| 20 | //mbg merge 7/17/06 changed to alloca |
| 21 | //int16 temp[Count]; /* Yay. Is this the first use of this "feature" of C in FCE Ultra? */ |
| 22 | int16 *temp = (int16*)alloca(Count*2); |
| 23 | |
| 24 | int16 *dest; |
| 25 | int x; |
| 26 | |
| 27 | #ifndef __WIN_DRIVER__ |
| 28 | if(!soundlog) return; |
| 29 | #else |
| 30 | if(!soundlog && !FCEUI_AviIsRecording()) return; |
| 31 | #endif |
| 32 | |
| 33 | dest=temp; |
| 34 | x=Count; |
| 35 | |
| 36 | //mbg 7/28/06 - we appear to be guaranteeing little endian |
| 37 | while(x--) |
| 38 | { |
| 39 | int16 tmp=*Buffer; |
| 40 | |
| 41 | *(uint8 *)dest=(((uint16)tmp)&255); |
| 42 | *(((uint8 *)dest)+1)=(((uint16)tmp)>>8); |
| 43 | dest++; |
| 44 | Buffer++; |
| 45 | } |
| 46 | if(soundlog) |
| 47 | wsize+=fwrite(temp,1,Count*sizeof(int16),soundlog); |
| 48 | |
| 49 | #ifdef __WIN_DRIVER__ |
| 50 | if(FCEUI_AviIsRecording()) |
| 51 | { |
| 52 | FCEUI_AviSoundUpdate((void*)temp, Count); |
| 53 | } |
| 54 | #endif |
| 55 | } |
| 56 | |
| 57 | int FCEUI_EndWaveRecord() |
| 58 | { |
no test coverage detected