Exemplo n.º 1
0
//
// This is used to setup the hardware configuration Port A of the 6821 PIA U10 for output
//
PERROR
CWmsSoundBaseGame::onBankSwitchSetupPIA1A(
    void *cWmsSoundBaseGame
)
{
    PERROR            error     = errorSuccess;
    CWmsSoundBaseGame *thisGame = (CWmsSoundBaseGame *) cWmsSoundBaseGame;
    ICpu              *cpu      = thisGame->m_cpu;

    // Set DDR (xxxxx0xx)
    error = cpu->memoryWrite(addressPIA1A+1, 0x00);     

    if (SUCCESS(error))
    {
        // Set PA0-PA7 as output pins
        error = cpu->memoryWrite(addressPIA1A, 0xFF); 
    }

    if (SUCCESS(error))
    {
        // Disable CA1 (xxxxxx00), Set PR (xxxxx1xx), Set CA2 speech data output low (xx110xxx)
        error = cpu->memoryWrite(addressPIA1A+1, 0x34);    
    }

    if (SUCCESS(error))
    {
        // Set PA0-PA7 outputs low
        error = cpu->memoryWrite(addressPIA1A, 0x00); 
    }

    return error;
}
Exemplo n.º 2
0
//
// This is used to setup the hardware configuration Port B of the 6821 PIA U10 for input
//
PERROR
CWmsSoundBaseGame::onBankSwitchSetupPIA1B(
    void *cWmsSoundBaseGame
)
{
    PERROR            error     = errorSuccess;
    CWmsSoundBaseGame *thisGame = (CWmsSoundBaseGame *) cWmsSoundBaseGame;
    ICpu              *cpu      = thisGame->m_cpu;

    // Set DDR (xxxxx0xx)
    error = cpu->memoryWrite(addressPIA1B+1, 0x00);     

    if (SUCCESS(error))
    {
        // Set PB0-PB7 as input pins
        error = cpu->memoryWrite(addressPIA1B, 0x00); 
    }

    if (SUCCESS(error))
    {
        // Enable CB1 low > high IRQ (xxxxxx11), Set PR (xxxxx1xx), Set CB2 speech clock output low (xx110xxx)
        error = cpu->memoryWrite(addressPIA1B+1, 0x37); 
    }

    return error;
}
//
// This is used to setup the 8255 to reflect the hardware configuration:
//   - Port A (All) Mode 0 Input
//   - Port B (All) Mode 0 Input
//   - Port C (Lo)  Mode 0 Input
//   - Port C (Hi)  Mode 0 Output
//
//     == 1 0010 011 == 0x93
//
// We also need to set the initial state of the Port C outputs to idle (Hi)
// using the bit Set\Reset command.
//   - PC4 100 1 == 0x09
//   - PC5 101 1 == 0x0B
//   - PC6 110 1 == 0x0D
//
PERROR
CMoneyMoneyBaseGame::onBankSwitchSetup8255(
    void *cMoneyMoneyBaseGame
)
{
    PERROR              error     = errorSuccess;
    CMoneyMoneyBaseGame *thisGame  = (CMoneyMoneyBaseGame *) cMoneyMoneyBaseGame;
    ICpu                *cpu       = thisGame->m_cpu;

    error = cpu->memoryWrite(0x7803, 0x93);

    if (SUCCESS(error))
    {
        error = cpu->memoryWrite(0x7803, 0x09);
    }

    if (SUCCESS(error))
    {
        error = cpu->memoryWrite(0x7803, 0x0B);
    }

    if (SUCCESS(error))
    {
        error = cpu->memoryWrite(0x7803, 0x0D);
    }

    return error;
}
Exemplo n.º 4
0
//
// Custom function for testing the optional speech board 55516 CVSDM Chip U1
// The CVSDM chip has two inputs:
// Speech data is fed from 6821 PAI U10 Pin 39 CA2
// Speech clock is fed from 6821 PAI U10 Pin 19 CB2
//
// On each speech clock pulse the CVSDM chip increases the slope if speech data is high and decrease it if low
//
PERROR
CWmsSoundBaseGame::soundTestCVSDM(
    void *context
)
{
    PERROR            error     = errorSuccess;
    CWmsSoundBaseGame *thisGame = (CWmsSoundBaseGame *) context;
    ICpu              *cpu      = thisGame->m_cpu;

    errorCustom->code = ERROR_SUCCESS;
    errorCustom->description = "CVSDM Tested!";

    // Disable CA1 (xxxxxx00), Set PR (xxxxx1xx), Set CA2 speech data output low (xx110xxx) 
    error = cpu->memoryWrite(addressPIA1A+1, 0x34);

    if (SUCCESS(error))
    {
        // Enable CB1 low > high IRQ (xxxxxx11), Set PR (xxxxx1xx), Set CB2 speech clock output low (xx110xxx)
        error = cpu->memoryWrite(addressPIA1B+1, 0x37);
    }  

    if (SUCCESS(error))
    {
        //
        // CVSDM waveform parameters
        //
        byte change[]  = { 10, 11, 10, 13, 15, }; // number of clocks before change of data state min~10 max~25
        byte direction = 0;                       // counter for set slope increase/decrease
        int loops      = 1000;                    // how many times the wave is repeated

        for (int step = 0; step < sizeof(change); step++)
        {
            for (int loop = 0; loop < loops; loop++)
            {
                // CB2 speech clock low
                cpu->memoryWrite(addressPIA1B+1, 0x3F); 

                // CA2 speech data high
                if (direction == 0) cpu->memoryWrite(addressPIA1A+1, 0x3C);   

                // CA2 speech data low       
                if (direction == change[step]) cpu->memoryWrite(addressPIA1A+1, 0x34);                   
                
                // CB2 speech clock high
                cpu->memoryWrite(addressPIA1B+1, 0x37);

                direction++;
                if (direction == change[step] * 2) direction = 0;
            }
        }
        error = errorCustom;
    }

    return error;
}
Exemplo n.º 5
0
//
// Custom function for testing the 6821 PIA U10 Bank A outputs to the MC1408 DAC U13 and the analog sound hardware
//
PERROR
CWmsSoundBaseGame::soundTestDAC(
    void *context
)
{
    PERROR            error     = errorSuccess;
    CWmsSoundBaseGame *thisGame = (CWmsSoundBaseGame *) context;
    ICpu              *cpu      = thisGame->m_cpu;

    errorCustom->code = ERROR_SUCCESS;
    errorCustom->description = "DAC Tested!";

    // Firstly initialse PIA1A in case the output test hasn't been run

    // Set DDR (xxxxx0xx)
    error = cpu->memoryWrite(addressPIA1A+1, 0x00);     

    if (SUCCESS(error))
    {
        // Set PA0-PA7 as output pins
        error = cpu->memoryWrite(addressPIA1A, 0xFF); 
    }

    if (SUCCESS(error))
    {
        // Disable CA1 (xxxxxx00), Set PR (xxxxx1xx), Set CA2 output low (xx110xxx)
        error = cpu->memoryWrite(addressPIA1A+1, 0x34);    
    }

    if (SUCCESS(error))
    {
        // Set PA0-PA7 outputs low
        error = cpu->memoryWrite(addressPIA1A, 0x00); 
    }

    if (SUCCESS(error))
    {
        //
        // DAC waveform parameters
        //
        //   step         {   0,   1,   2,   3,   4,   5,}
        byte loops[]    = {  40,  25,  50, 100,  50, 100, }; // how many times the waveform is repeated      max=255
        byte delay[]    = {   0,  15,  30,   0,  25,   0, }; // how long each data value is left on the DAC  max=255
        byte waveform[] = {   2,   2,   0,   0,   1,   1, }; // waveform shape 0=Sine 1=Sawtooth 2=Square
        byte sine[] = { 0x80,0xa0,0xbf,0xda,0xee,0xfb,0xff,0xfb,0xee,0xda,0xbf,0xa0,0x80,0x5f,0x40,0x25,0x11,0x4,0x0,0x4,0x11,0x25,0x40,0x5f,0x80, }; // 24 Points - any more is just too slow

        for (int step = 0; step < sizeof(loops); step++)
        {
            for (int loop = 0; loop < loops[step]; loop++)
            {
                for (int point = 0; point < sizeof(sine); point++)
                {
                    switch (waveform[step]) {
                        case 0:
                            // Sine Wave
                            cpu->memoryWrite(addressPIA1A, sine[point]);
                            delayMicroseconds(delay[step]);
                            break;
                        case 1:
                            // Sawtooth Wave
                            cpu->memoryWrite(addressPIA1A, int (256/sizeof(sine)) * point);
                            delayMicroseconds(delay[step]);
                            break;
                        case 2:
                            // Square Wave
                            cpu->memoryWrite(addressPIA1A, 0);
                            delayMicroseconds(delay[step]);
                            cpu->memoryWrite(addressPIA1A, 255);
                            delayMicroseconds(delay[step]);
                            break;
                    }
                }
            }
        }

        error = errorCustom;
    }

    return error;
}