Homebrew Homebrew Development

  • Thread starter Thread starter aliak11
  • Start date Start date
  • Views Views 1,475,135
  • Replies Replies 6,048
  • Likes Likes 54
That sounds great! I didn't know about that function, maybe I should first work through the documentation of ctrulib... (but it's so big!) I'm gonna try this out and tell you my progress. :)

You can also use hidKeysHeld instead of hidKeysDown, save the result in a variable at the end of the main loop and then add to the check something like oldvalues != values
 
I am trying to read c-pad and touch positions from within 3ds linux. Ctrulib does this by reading the HID shared memory, which is updated by the HID firmware module, which AFAIK does not run under 3ds linux. Can anyone point me in the right direction to figure this out? I imagine I will have to comminucate with the Auxilliary Microcontroller over i2c, but I have no idea what addresses to use.
 
I am trying to read c-pad and touch positions from within 3ds linux. Ctrulib does this by reading the HID shared memory, which is updated by the HID firmware module, which AFAIK does not run under 3ds linux. Can anyone point me in the right direction to figure this out? I imagine I will have to comminucate with the Auxilliary Microcontroller over i2c, but I have no idea what addresses to use.
Best thing to do is develop a joystick driver and get rid of the "software keyboard driver". But then you won't have a keyboard, so you'll have to write a touchscreen keyboard similar to dslinux.
 
Best thing to do is develop a joystick driver and get rid of the "software keyboard driver". But then you won't have a keyboard, so you'll have to write a touchscreen keyboard similar to dslinux.
I'm planning to make a touch keyboard, and have the c-pad as mouse. Typing with the d-pad is very tedious.
 
I'm planning to make a touch keyboard, and have the c-pad as mouse. Typing with the d-pad is very tedious.
You are correct, the services aren't running so you will have to communicate with the mapped registers directly. Unfortunately, I haven't come across any documentation on the touchscreen or the circlepad
 
Unsigned 65000 pcm16 to signed would be 65000-32768

Looks like audio is completely distorted if i just cast it and looks also messed up if i add 32768 to the samples:
Code:
//prefill audio buffer with music
   for (j=0; j<NUM_SAMPS/2; j+=2){
     sdlbuf[j] = musbuf[j/2] + 32768;
     sdlbuf[j+1] = musbuf[j/2] + 32768;
   }
   
   // now add in sound effects
   for (j=0; j<NUM_SFX; j++) {
     if (SoundPlaying[j] == -1)
       continue;

     // compute L/R scale based on player position and stored sound position
     if (SoundPositioned[j]) {
       SetSoundLoc(SoundGX[j], SoundGY[j]);
       L = leftchannel;
       R = rightchannel;
     }

     // now add sound effect data to buffer
     for (i = 0; i < NUM_SAMPS; i++) {
       samp = (SoundData[j][(SoundPlayPos[j] >> 16)] << 8)^0x8000;
       if (SoundPositioned[j]) {
         snd = samp*(16-L)>>5;
         snd = snd + 32768;
         sdlbuf[i+0] += snd;
         snd = samp*(16-R)>>5;
         snd = snd + 32768;
         sdlbuf[NUM_SAMPS+i+0] += snd;
       } else {
         snd = samp>>2;
         snd = snd + 32768;
         sdlbuf[i+0] += snd;
         sdlbuf[NUM_SAMPS+i+0] += snd;
       }
       SoundPlayPos[j] += 10402; // 7000 / 44100 * 65536
       if ((SoundPlayPos[j] >> 16) >= SoundPlayLen[j]) {
         SoundPlayPos[j] -= (SoundPlayLen[j] << 16);
         SoundLen[j] -= 4096;
         SoundPlayLen[j] = (SoundLen[j] < 4096) ? SoundLen[j] : 4096;
         if (SoundLen[j] <= 0) {
           SoundPlaying[j] = -1;
           CurDigi[j] = -1;
           i = NUM_SAMPS;
         } else {
           SoundPage[j]++;
           SoundData[j] = PM_GetSoundPage(SoundPage[j]);
         }
       }
     }
   }
 
Looks like audio is completely distorted if i just cast it and looks also messed up if i add 32768 to the samples:
Code:
//prefill audio buffer with music
   for (j=0; j<NUM_SAMPS/2; j+=2){
     sdlbuf[j] = musbuf[j/2] + 32768;
     sdlbuf[j+1] = musbuf[j/2] + 32768;
   }
  
   // now add in sound effects
   for (j=0; j<NUM_SFX; j++) {
     if (SoundPlaying[j] == -1)
       continue;

     // compute L/R scale based on player position and stored sound position
     if (SoundPositioned[j]) {
       SetSoundLoc(SoundGX[j], SoundGY[j]);
       L = leftchannel;
       R = rightchannel;
     }

     // now add sound effect data to buffer
     for (i = 0; i < NUM_SAMPS; i++) {
       samp = (SoundData[j][(SoundPlayPos[j] >> 16)] << 8)^0x8000;
       if (SoundPositioned[j]) {
         snd = samp*(16-L)>>5;
         snd = snd + 32768;
         sdlbuf[i+0] += snd;
         snd = samp*(16-R)>>5;
         snd = snd + 32768;
         sdlbuf[NUM_SAMPS+i+0] += snd;
       } else {
         snd = samp>>2;
         snd = snd + 32768;
         sdlbuf[i+0] += snd;
         sdlbuf[NUM_SAMPS+i+0] += snd;
       }
       SoundPlayPos[j] += 10402; // 7000 / 44100 * 65536
       if ((SoundPlayPos[j] >> 16) >= SoundPlayLen[j]) {
         SoundPlayPos[j] -= (SoundPlayLen[j] << 16);
         SoundLen[j] -= 4096;
         SoundPlayLen[j] = (SoundLen[j] < 4096) ? SoundLen[j] : 4096;
         if (SoundLen[j] <= 0) {
           SoundPlaying[j] = -1;
           CurDigi[j] = -1;
           i = NUM_SAMPS;
         } else {
           SoundPage[j]++;
           SoundData[j] = PM_GetSoundPage(SoundPage[j]);
         }
       }
     }
   }
There is quite a bit going on in this sample - with no data types visible it makes it a little more difficult. The music part looks more or less correct. Though I think it should be - 32768 rather than + 32768(the divide by 2 on the counter has me a little confused). The sound effect mixing part is already applying some conversion ^0x8000. Which would be the same is -32768 for an unsigned short. The mixing part brings in some additional issues too- overflow etc.
 
the divide by 2 thing is done cause musbuf stores a mono music and sdlbuf (buffer which plays csnd) is for a stereo PCM16. Anyway according to what i found on the net, it seems that C performs automatically proper conversion when a cast is called (i suppose it works also for implicit casts) so the problem could be related to something other maybe? (Changing interpolation seems to not change the output, maybe it could be a floating point issue (for example, vorbisfile works fine with software fp but produce distorted sounds with hardware fp).
 
the divide by 2 thing is done cause musbuf stores a mono music and sdlbuf (buffer which plays csnd) is for a stereo PCM16. Anyway according to what i found on the net, it seems that C performs automatically proper conversion when a cast is called (i suppose it works also for implicit casts) so the problem could be related to something other maybe? (Changing interpolation seems to not change the output, maybe it could be a floating point issue (for example, vorbisfile works fine with software fp but produce distorted sounds with hardware fp).
No, C does not auto convert unsigned/signed samples it converts unsigned/signed integers. Try just the music with unsigned shorts and use ^0x8000 instead of + or - 32768.
 
No, C does not auto convert unsigned/signed samples it converts unsigned/signed integers. Try just the music with unsigned shorts and use ^0x8000 instead of + or - 32768.

Yeah but sdlbuf is declared as a u16*,musbuf as a short int* and snd as a short int so when musbuf is copied in sdlbuf (for example) it performs the proper cast i suppose.
 
Yeah but sdlbuf is declared as a u16*,musbuf as a short int* and snd as a short int so when musbuf is copied in sdlbuf (for example) it performs the proper cast i suppose.
The two are not related. Casting does not change the data itself - it only impacts how the data will be treated - sign extension etc. conversion actually changes the data. What is this for? Is it possible to see the whole code?
 
What is a good current FTP Homebrew I can use that does not cause disconnects?
I was using FTPBrony but I am unsure what version I am using and would like to FTP to my 3DS.
 
What is a good current FTP Homebrew I can use that does not cause disconnects?
I was using FTPBrony but I am unsure what version I am using and would like to FTP to my 3DS.
Since you posted on the homebrew development thread I'm going to answer somewhat on topic.
Clone the repo and compile it. You will need the latest devkitarm and ctrulib. Also instructions on how to compile are on the readme
 

Site & Scene News

Popular threads in this forum