WAVRecord::WAVRecord(const char *path, double SoundRate_arg, uint32 SoundChan_arg) : wavfile(path, FileStream::MODE_WRITE_SAFE) { Finished = false; PCMBytesWritten = 0; SoundRate = SoundRate_arg; SoundChan = SoundChan_arg; memset(&raw_headers, 0, sizeof(raw_headers)); MDFN_en32msb(&raw_headers[0x00], 0x52494646); // "RIFF" // @ 0x04 = total file size - 8 bytes MDFN_en32msb(&raw_headers[0x08], 0x57415645); // "WAVE" MDFN_en32msb(&raw_headers[0x0C], 0x666d7420); // "fmt " MDFN_en32lsb(&raw_headers[0x10], 16); MDFN_en16lsb(&raw_headers[0x14], 1); // PCM format MDFN_en16lsb(&raw_headers[0x16], SoundChan); // Number of sound channels MDFN_en32lsb(&raw_headers[0x18], SoundRate); // Sampling rate MDFN_en32lsb(&raw_headers[0x1C], SoundRate * SoundChan * sizeof(int16)); //Byte rate MDFN_en16lsb(&raw_headers[0x20], SoundChan * sizeof(int16)); // Block("audio frame" in Mednafen) alignment MDFN_en16lsb(&raw_headers[0x22], sizeof(int16) * 8); // Bits per sample. MDFN_en32msb(&raw_headers[0x24], 0x64617461); // "data" // @ 0x28 = bytes of PCM data following wavfile.write(raw_headers, sizeof(raw_headers)); }
virtual void TransformInput(uint8* data, const bool DisableSR) override { if(DisableSR) { uint16 tmp = MDFN_de16lsb(data); if((tmp & 0xC0) == 0xC0) tmp &= ~0xC0; MDFN_en16lsb(data, tmp); } }
void WAVRecord::WriteSound(const int16 *SoundBuf, uint32 NumSoundFrames) { uint32 NumSoundSamples = NumSoundFrames * SoundChan; while(NumSoundSamples > 0) { int16 swap_buf[256]; uint32 s_this_time = std::min((uint32)NumSoundSamples, (uint32)256); for(uint32 i = 0; i < s_this_time; i++) MDFN_en16lsb((uint8 *)&swap_buf[i], SoundBuf[i]); wavfile.write(swap_buf, s_this_time * sizeof(int16)); PCMBytesWritten += s_this_time * sizeof(int16); NumSoundSamples -= s_this_time; SoundBuf += s_this_time; } }
void InputDevice_DualShock::UpdateInput(const void *data) { uint8 *d8 = (uint8 *)data; uint8* const rumb_dp = &d8[3 + 16]; buttons[0] = d8[0]; buttons[1] = d8[1]; cur_ana_button_state = d8[2] & 0x01; for(int stick = 0; stick < 2; stick++) { for(int axis = 0; axis < 2; axis++) { const uint8* aba = &d8[3] + stick * 8 + axis * 4; int32 tmp; tmp = 32767 + MDFN_de16lsb(&aba[0]) - MDFN_de16lsb(&aba[2]); tmp = (tmp * 0x100) / 0xFFFF; axes[stick][axis] = tmp; } } //printf("%3d:%3d, %3d:%3d\n", axes[0][0], axes[0][1], axes[1][0], axes[1][1]); //printf("RUMBLE: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", rumble_magic[0], rumble_magic[1], rumble_magic[2], rumble_magic[3], rumble_magic[4], rumble_magic[5]); //printf("%d, 0x%02x 0x%02x\n", da_rumble_compat, rumble_param[0], rumble_param[1]); if(da_rumble_compat == false) { uint8 sneaky_weaky = 0; if(rumble_param[0] == 0x01) sneaky_weaky = 0xFF; MDFN_en16lsb(rumb_dp, (sneaky_weaky << 0) | (rumble_param[1] << 8)); } else { uint8 sneaky_weaky = 0; if(((rumble_param[0] & 0xC0) == 0x40) && ((rumble_param[1] & 0x01) == 0x01)) sneaky_weaky = 0xFF; MDFN_en16lsb(rumb_dp, sneaky_weaky << 0); } //printf("%d %d %d %d\n", axes[0][0], axes[0][1], axes[1][0], axes[1][1]); // // // CheckManualAnaModeChange(); // // Encode analog mode state last. // d8[2] &= ~0x6; d8[2] |= (analog_mode ? 0x02 : 0x00); d8[2] |= (analog_mode_locked ? 0x04 : 0x00); }