devkitPro / wut

Let's try to make a Wii U Toolchain / SDK for creating rpx/rpl.
zlib License
244 stars 52 forks source link

Add MIC lib (mic.rpl) #214

Closed NessieHax closed 2 years ago

exjam commented 2 years ago

Please rename the types from snake_case to PascalCase to keep consistency with the rest of the project.

NessieHax commented 2 years ago

mic_status_t is the exact name found in a (debug)symbol should i change that too ?

revvv commented 2 years ago

Have you seen mic.h from libcafe?

NessieHax commented 2 years ago

no i havent i just REd it out of games that have debug symbols

Maschell commented 2 years ago

libcafe seems to be copy pasted straight from the official SDK, so probably not really a good source of information from a legal standpoint

NessieHax commented 2 years ago

lol fr 😳

revvv commented 2 years ago

Ah, I see. Too bad. Originally I planned to do a PR for camera.h

My first approach to get camera.h was to disassemble an app with Ghidra, but then I found libcafe...

NessieHax commented 2 years ago

@Fangal-Airbag already REd most of camera.rpl

revvv commented 2 years ago

Do you have a working mic.h example? I was not able to get it running... MICInit() returns error code -85

NessieHax commented 2 years ago

Do you have a working mic.h example? I was not able to get it running... MICInit() returns error code -85

i do have code that i used for testing it its not pretty or anything but gets the job done

#include <whb/proc.h>
#include <whb/log.h>
#include <whb/log_udp.h>
#include <whb/gfx.h>

#include <mic/mic.h>

#include <string.h>

#define SHUTDOWN_AND_EXIT() \
   WHBGfxShutdown(); \
   WHBProcShutdown(); \
   WHBLogUdpDeinit(); \
   return -1

static uint8_t s_audioBuffer[0xA000];
static MICWorkMem s_setup = {
   0x2000,
   s_audioBuffer
};

int main(int argc, char **argv)
{
   WHBLogUdpInit();
   WHBProcInit();
   WHBGfxInit();
   MICError mic_err;
   MICHandle mic_handle = MICInit(MIC_INSTANCE_0, 0, &s_setup, &mic_err);
   if (mic_err != MIC_ERROR_OK)
   {
      WHBLogPrintf("Failed to initialize mic (%d)", mic_err);
      SHUTDOWN_AND_EXIT();
   }

   mic_err = MICOpen(mic_handle);
   if (mic_err != MIC_ERROR_OK)
   {
      WHBLogPrintf("Failed to open mic (%d)", mic_err);
      SHUTDOWN_AND_EXIT();
   }

   WHBLogPrint("Entering Draw Loop");
   while (WHBProcIsRunning())
   {
      WHBGfxBeginRender();
      WHBGfxBeginRenderDRC();

      WHBGfxClearColor(0.3f, 0.0f, 0.175f, 0.25f);
      WHBGfxFinishRenderDRC();
      WHBGfxFinishRender();
   }

   mic_err = MICClose(mic_handle);
   if (mic_err != MIC_ERROR_OK)
   {
      WHBLogPrintf("Failed to close mic (%d)", mic_err);
      SHUTDOWN_AND_EXIT();
   }

   mic_err = MICUninit(mic_handle);
   if (mic_err != MIC_ERROR_OK)
   {
      WHBLogPrintf("Failed to uninit mic (%d)", mic_err);
      SHUTDOWN_AND_EXIT();
   }

   WHBLogPrintf("Exiting...");
   WHBGfxShutdown();
   WHBProcShutdown();
   WHBLogUdpDeinit();
   return 0;
}
revvv commented 2 years ago

@NessieHax Thank you! It works!

NessieHax commented 2 years ago

@exjam i updated the code style :)

exjam commented 2 years ago

Thanks! Pushed as 8fdfd12d6c02106717fe3d090595968194587825