Skip to content

Commit

Permalink
better conformity to spec
Browse files Browse the repository at this point in the history
  • Loading branch information
hooby3dfx committed Feb 1, 2014
1 parent e1970cf commit 0c11acb
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 16 deletions.
30 changes: 21 additions & 9 deletions core/hw/maple/maple_devs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ struct maple_microphone: maple_base

case MDCF_GetCondition:
{
LOGD("maple_microphone::dma MDCF_GetCondition");
//this was copied from the controller case with just the id replaced!

//PlainJoystickState pjs;
Expand Down Expand Up @@ -781,14 +782,25 @@ struct maple_microphone: maple_base
{
case 0x01:
{
LOGD("maple_microphone::dma MDCF_MICControl someone wants some data!");
LOGD("maple_microphone::dma MDCF_MICControl someone wants some data! (2nd word) %#010x\n", subcommand);

//do i need this?
//w32(MFID_4_Mic);
w32(MFID_4_Mic);

//from what i can tell this is up to spec but results in transmit again
//w32(secondword);

//32 bit header
w8(0x04);//status (just the bit for recording)
w8(0x0f);//gain (default)
w8(0);//exp ?

if(get_mic_data(micdata)){
w8(240);//ct (240 samples)
wptr(micdata, SIZE_OF_MIC_DATA);
}else{
w8(0);
}

get_mic_data(micdata);
wptr(micdata, SIZE_OF_MIC_DATA);

return MDRS_DataTransfer;
}
case 0x02:
Expand All @@ -801,9 +813,9 @@ struct maple_microphone: maple_base
return MDRS_DeviceReply;
case MDRE_TransminAgain:
LOGD("maple_microphone::dma MDCF_MICControl MDRE_TransminAgain");
//w32(MFID_4_Mic);
wptr(micdata, SIZE_OF_MIC_DATA);
return MDRS_DataTransfer;
//apparently this doesnt matter
//wptr(micdata, SIZE_OF_MIC_DATA);
return MDRS_DeviceReply;//MDRS_DataTransfer;
default:
LOGD("maple_microphone::dma UNHANDLED secondword %#010x\n",secondword);
break;
Expand Down
4 changes: 2 additions & 2 deletions core/hw/maple/maple_devs.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ struct maple_device
};

maple_device* maple_Create(MapleDeviceType type);
#define SIZE_OF_MIC_DATA 512 //ALSO DEFINED IN SipEmulator.java
void get_mic_data(u8* buffer); //implemented in Android.cpp
#define SIZE_OF_MIC_DATA 480 //ALSO DEFINED IN SipEmulator.java
int get_mic_data(u8* buffer); //implemented in Android.cpp
15 changes: 14 additions & 1 deletion docs/microphone support notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,17 @@ plan:
== 176.4 kbit/s
== 22050 bytes/s

maximum size of a Maple Bus packet is 256 words (1024 bytes)
maximum size of a Maple Bus packet is 256 words (1024 bytes)


================
Games that can use mic:
-Seaman
-Alien Front Online
-Planet Ring
-Mr Driller
-Otoire
-Propeller Arena
-Visual Park
-???

5 changes: 3 additions & 2 deletions shell/android/jni/src/Android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,14 @@ bool os_IsAudioBuffered()
return jenv->CallIntMethod(track,writemid,jsamples,-1)==0;
}

void get_mic_data(u8* buffer)
int get_mic_data(u8* buffer)
{
jbyteArray jdata = (jbyteArray)jenv->CallObjectMethod(sipemu,getmicdata);
if(jdata==NULL){
LOGW("get_mic_data NULL");
return;
return 0;
}
jenv->GetByteArrayRegion(jdata, 0, SIZE_OF_MIC_DATA, (jbyte*)buffer);
jenv->DeleteLocalRef(jdata);
return 1;
}
4 changes: 2 additions & 2 deletions shell/android/src/com/reicast/emulator/SipEmulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class SipEmulator extends Thread {
static final int BUFFER_SIZE = 22050;
//this needs to get set to the amount the mic normally sends per data request
//...cant be bigger than a maple packet
static final int ONE_BLIP_SIZE = 512; //ALSO DEFINED IN maple_devs.h
//static final long TIME_TO_WAIT_BETWEEN_POLLS = 1000 / (BUFFER_SIZE / ONE_BLIP_SIZE);
// 240 16 (or 14) bit samples
static final int ONE_BLIP_SIZE = 480; //ALSO DEFINED IN maple_devs.h

private AudioRecord record;
private LinkedList<byte[]> bytesReadBuffer;
Expand Down

0 comments on commit 0c11acb

Please sign in to comment.