Ignore:
Timestamp:
Apr 24, 2000, 9:45:21 PM (25 years ago)
Author:
sandervl
Message:

Fixed wave volume, recording gain + wave recording

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sbliveos2/trunk/drv16/mpu401.cpp

    r142 r147  
    3939
    4040#include "parse.h"
     41#include "ossidc.h"
    4142
    4243
     
    4849   static char szName[] = "SBLive #";  // Instance name for RTMIDI.  A number will be appended.
    4950   static char szSuffix[] = "0";       // Printable char that is appended to szName.
    50 
    51    usDataPort = 0x300;
    52    usStatPort = 0x300 + 1;
    5351
    5452   // RTMIDI (MIDI.SYS) related stuff
     
    5957   // When we have an IRQ and a send capability, add next line.
    6058   // ulCapabilities |= MIDICAPSA_OUTPUT;
    61 }
    62 
    63 
    64 #define TIMEOUT   60000
    65 
    66 unsigned MPUcommand(USHORT usDataPort, BYTE b)
    67 /* Returns 0 when command is properly accepted by the specified port;
    68  * Returns 1 - 4 to indicate various timeout conditions.
    69  */
    70 {
    71    unsigned i;
    72    const usStatPort = usDataPort + 1;
    73 
    74    i=1000;
    75    while (--i) {
    76       if (inp(usStatPort) & DSR) break;
    77       inp(usDataPort);
    78       iodelay(1);                      // Delay >= 0.5 uSec
    79    }
    80    if ( !i ) {                         // >500 millisecond wait?
    81       return 4;
    82    }
    83 
    84    for (i=0; i<TIMEOUT; i++) {
    85       if (!(inp(usStatPort) & DRR)) {  // wait until it's ready
    86          iodelay(1);                   // just to be safe
    87          outp(usStatPort,b);
    88          iodelay(1);                   // just to be safe
    89          for (i=0; i<TIMEOUT; i++) {
    90             if (!(inp(usStatPort) & DSR)) {
    91                iodelay(1);             // just to be safe
    92                i=inp(usDataPort);
    93                if (i == 0xFE)
    94                   return 0;
    95                else {
    96                   return 3;
    97                }
    98             }
    99             iodelay(1);
    100          }
    101          if (b == 0xFF) {
    102             return 0;
    103          }
    104          else {
    105             return 1;
    106          }
    107       }
    108       iodelay(1);
    109    }
    110 
    111    return 2;
     59
     60   midiOutStreamId = 0;
     61   midiInStreamId  = 0;
    11262}
    11363
     
    174124int MPU_401::writeByte(BYTE b)
    175125{
    176    unsigned i;
    177 
    178    for (i=0; i<TIMEOUT; i++) {
    179       cli();
    180       if (!(inp(usStatPort) & DRR)) {
    181          outp(usDataPort, b);
    182          sti();
    183          return 1;
    184       }
    185       sti();
    186       iodelay(1);
    187    }
     126   //TODO:
    188127   return 0;
    189128}
     
    191130int MPU_401::readByte(void)
    192131{
    193    unsigned i;
    194 
    195    for (i=0; i<TIMEOUT; i++) {
    196       cli();
    197       if (!(inp(usStatPort) & DSR)) {
    198          i=inp(usDataPort);
    199          sti();
    200          return i;
    201       }
    202       sti();
    203       iodelay(1);
    204    }
     132   //TODO:
    205133   return -1;
    206134}
    207135
    208 /* MPU_401::_iInitialize
    209  * ### Need cleanup return codes - currently they are not consistent
    210  * ### or documented.  Currently, returns 0 on SUCCESS.
    211  */
    212 int MPU_401::_iInitialize(void)
    213 {
    214    int rc;              // Return code from MPUcommand().
    215 
    216    rc = MPUcommand(usDataPort, 0xFF);
    217    if (rc == 0)
    218       rc = MPUcommand(usDataPort, 0x3F);
    219 
    220    return rc;
    221 }
    222 
    223136#pragma off (unreferenced)
    224137
     
    231144{
    232145   BOOL rc;
    233    _iInitialize();
    234146
    235147   // Start timer on 4 mSec interval.
     
    263175USHORT MPU_401::RTMIDI_OpenReceive(void)
    264176{
    265    //### Need to add serialization b/t MMPM/2 + RTMIDI, plus mult RTMIDI opens.
    266 
    267    USHORT us = _iInitialize();
    268    if (us)
    269       return MIDIERRA_HW_FAILED;
    270    else
    271       return 0;
     177   if(midiInStreamId == 0) {
     178          midiInStreamId = OSS16_OpenMidiStream(MIDI_RECEIVE);
     179   }
     180   return (midiInStreamId) ? 0 : MIDIERRA_HW_FAILED;
    272181}
    273182
    274183USHORT MPU_401::RTMIDI_OpenSend(void)
    275184{
    276    //### Need to add serialization b/t MMPM/2 + RTMIDI, plus mult RTMIDI opens.
    277    //### Send capability pending but not currently implemented.
    278 
    279    return MIDIERRA_HW_FAILED;
     185   if(midiOutStreamId == 0) {
     186          midiOutStreamId = OSS16_OpenMidiStream(MIDI_SEND);
     187   }
     188   return (midiOutStreamId) ? 0 : MIDIERRA_HW_FAILED;
    280189}
    281190
    282191USHORT MPU_401::RTMIDI_CloseReceive(void)
    283192{
    284    MPUcommand(usDataPort, 0xFF);
     193   OSS16_CloseMidiStream(MIDI_RECEIVE, midiInStreamId);
    285194   return 0;
    286195}
     
    288197USHORT MPU_401::RTMIDI_CloseSend(void)
    289198{
    290    MPUcommand(usDataPort, 0xFF);
    291    return 0;
    292 }
    293 
     199   OSS16_CloseMidiStream(MIDI_SEND, midiOutStreamId);
     200   return 0;
     201}
     202
Note: See TracChangeset for help on using the changeset viewer.