Beispiel #1
0
bool QTapeView::tapeReadCallback(unsigned int samples)
{
    if (m_hTapeWavPcmFile == (HWAVPCMFILE)INVALID_HANDLE_VALUE) return 0;
    if (m_okTapeRecording) return 0;
    if (samples == 0) return 0;

    unsigned int value = 0;
    for (unsigned int i = 0; i < samples; i++)
    {
        value = WavPcmFile_ReadOne((HWAVPCMFILE)m_hTapeWavPcmFile);
    }
    BOOL result = (value > 0xffffffff / 2);

    DWORD wavLength = WavPcmFile_GetLength((HWAVPCMFILE)m_hTapeWavPcmFile);
    DWORD wavPos = WavPcmFile_GetPosition((HWAVPCMFILE)m_hTapeWavPcmFile);
    if (wavPos >= wavLength)  // End of tape
        this->stopTape();

    int wavFreq = WavPcmFile_GetFrequency((HWAVPCMFILE)m_hTapeWavPcmFile);
    if (wavPos - m_dwTapePositionShown > (DWORD)(wavFreq / 6) || !m_okTapePlaying)
    {
        this->updatePosition();
    }

    return result;
}
Beispiel #2
0
// Tape emulator callback used to read a tape recorded data.
// Input:
//   samples    Number of samples to play.
// Output:
//   result     Bit to put in tape input port.
BOOL CALLBACK TapeView_TapeReadCallback(unsigned int samples)
{
    if (samples == 0) return 0;

    // Scroll buffer
    memmove(m_TapeBuffer, m_TapeBuffer + samples, TAPE_BUFFER_SIZE - samples);

    UINT value = 0;
    for (UINT i = 0; i < samples; i++)
    {
        value = WavPcmFile_ReadOne(m_hTapeWavPcmFile);
        *(m_TapeBuffer + TAPE_BUFFER_SIZE - samples + i) = (BYTE)((value >> 24) & 0xff);
    }
    BOOL result = (value >= UINT_MAX / 2);

    InvalidateRect(m_hwndTapeGraph, NULL, FALSE);

    DWORD wavLength = WavPcmFile_GetLength(m_hTapeWavPcmFile);
    DWORD wavPos = WavPcmFile_GetPosition(m_hTapeWavPcmFile);
    if (wavPos >= wavLength)  // End of tape
        TapeView_StopTape();

    int wavFreq = WavPcmFile_GetFrequency(m_hTapeWavPcmFile);
    if (wavPos - m_dwTapePositionShown > (DWORD)(wavFreq / 6) || !m_okTapePlaying)
    {
        TapeView_UpdatePosition();
    }

//#if !defined(PRODUCT)
//    DebugPrintFormat(_T("Tape: %d\r\n"), result);
//#endif

    return result;
}