<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mouseroot</title>
    <description>The latest articles on DEV Community by Mouseroot (@mouseroot).</description>
    <link>https://dev.to/mouseroot</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F946349%2F50939e4a-1d71-4bf8-8614-dd6ae0970ba1.jpeg</url>
      <title>DEV Community: Mouseroot</title>
      <link>https://dev.to/mouseroot</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mouseroot"/>
    <language>en</language>
    <item>
      <title>MP3 files in Android for Unity3D</title>
      <dc:creator>Mouseroot</dc:creator>
      <pubDate>Mon, 17 Oct 2022 22:32:19 +0000</pubDate>
      <link>https://dev.to/mouseroot/mp3-files-in-android-for-unity3d-590o</link>
      <guid>https://dev.to/mouseroot/mp3-files-in-android-for-unity3d-590o</guid>
      <description>&lt;p&gt;Lets say you wanted to build an MP3 player in unity3D so you can listen to YOUR songs with a cool visualizer or maybe while playing a game.&lt;/p&gt;

&lt;p&gt;You could drag all the MP3 files into your unity project and simply play the files by changing the clip source of an audio source.&lt;/p&gt;

&lt;p&gt;However lets say you wanted to have the ability to add songs from your personal collection (assuming anyone collects MP3's anymore)&lt;/p&gt;

&lt;p&gt;It is not as easy as it seems, there is a solution that uses the NAudio API, However I found that it didn't actually work for android, It could read the file and even parse the music data and transcode it to a wav format...however it would not play when building for android and testing on the real device...&lt;/p&gt;

&lt;p&gt;This led me to search the unity marketplace which I usually try to avoid as I am usually low on funds and the free assets are usually not all that great, However I do know there are some gems in there, they are far and few between...&lt;/p&gt;

&lt;p&gt;That is until I found the Android Native Audio Asset package, this was actually a paid for asset that the developer decided to make free, and I am sure glad he did as it not only solved the problem but solved a really huge problem that I did not even foresee.&lt;/p&gt;

&lt;p&gt;That problem being the ability to CONTINUE to play the music while the screen was off or while the app was in the background and best of all, its all done in just a few lines of code...thats right most of all the heavy lifting has been done for us.&lt;/p&gt;

&lt;p&gt;So enough about the problem, lets look at the solution.&lt;/p&gt;

&lt;p&gt;first it would make sense to actually obtain the asset from the asset store.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://assetstore.unity.com/packages/tools/audio/android-native-audio-35295"&gt;Android Native Audio&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add it to your account so you can open the Package Manager and Import it into your project&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oVnpkwhJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rug208pfnn6cfouof1vp.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oVnpkwhJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rug208pfnn6cfouof1vp.jpg" alt="Package Manager" width="802" height="732"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next we need to call the API from a script.&lt;br&gt;
First lets get a list of all the songs within the android data folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;FileInfo&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;sdcard&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;$"&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;persistentDataPath&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;DirectoryInfo&lt;/span&gt; &lt;span class="n"&gt;dataDir&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;DirectoryInfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;sdcard&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dataDir&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetFiles&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Basically we create a path that points to the persistantDataPath, next we use the DirectoryInfo class to get information about that folder, including all the files, which we later store into a list of FileInfo, after this the sdcard array has a list of all the files within the folder,&lt;/p&gt;

&lt;p&gt;Next you would design some kind of interface for playing the media files, for now we are just going to have it play the first song as a demo.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;songID&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ANAMusic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sdcard&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;ANAMusic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;songID&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So first we load the first song and store the handle to it as an integer, the next 4 parameters of the load function specify how the music will be loaded and played and how it will react when the application loses focus or the screen turns off.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;ANAMusic.load(string audioFile, bool usePersistentDataPath = false, bool&lt;br&gt;
loadAsync = false, Action loadedCallback = null, bool playInBackground&lt;br&gt;
= false)&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Loads a music file into a native Android media player.
audioFile - The path to the music file, relative to Assets\StreamingAssets.
usePersistentDataPath - If true, audioFile is relative to Application.persistentDataPath. If false, it is
relative to Assets\StreamingAssets.
loadAsync - If true, the file is loaded asynchronously and the method immediately returns. If false, the method
will not return until the load has completed.
loadedCallback - If given, the method to call when the load is complete. Must take one int parameter which is
the loaded music ID.
playInBackground - If true, the music will continue playing when the game is not active. If false, the music will
be paused when the game is not active and resumed when it becomes active again.
Returns: int - The ID of the loaded music.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running the application on windows will not let the audio load, however if you build to android and place an mp3 file in the /Android/data/com.myprojectname/files/ running the project will play the mp3 and if you turn the screen off the song keeps playing.&lt;/p&gt;

&lt;p&gt;This opens the ability for users to play thier own music during your games or if you just want to build a really cool mp3 player( because those have also disappeared, the latest phones dont even have music players anymore)&lt;/p&gt;

&lt;p&gt;Also the asset comes with all the documentation in a nifty PDF format, I hope this helps anyone struggling to play mp3 files from the android file system in Unity.&lt;/p&gt;

</description>
      <category>unity3d</category>
      <category>tutorial</category>
      <category>csharp</category>
    </item>
    <item>
      <title>RX-500 Project-Updates</title>
      <dc:creator>Mouseroot</dc:creator>
      <pubDate>Mon, 17 Oct 2022 07:29:19 +0000</pubDate>
      <link>https://dev.to/mouseroot/rx-500-project-updates-33n4</link>
      <guid>https://dev.to/mouseroot/rx-500-project-updates-33n4</guid>
      <description>&lt;p&gt;I was keeping a small log of my project updates while I was working on the more internal aspects of the project, for the design and UI, I kept compiling to android to test and make sure the dimensions and anchors were set properly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10-3-2022&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Started to create a small VM inside the RX-500 Game Project&lt;/p&gt;

&lt;p&gt;I wanted to add the ability to both program for the virtual machine and learn to explore existing software and create exploits or discover vulnerabilities that would actually progress the story of the game.&lt;/p&gt;

&lt;p&gt;A, B, C, X, Y and SP Registers, Stack and Memory which the program code is loaded into.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10-5-2022&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;VM can run simple integer based array and would preform certain actions against registers and the stack, loading values into the basic registers of the virtual machine as well as the basic halt instruction that stops the virtual machine.&lt;/p&gt;

&lt;p&gt;It can place an array of bytes into the memory of the virtual machine by copying them “bit for bit”&lt;/p&gt;

&lt;p&gt;Started to work on the RX-500 instruction manual that would double as an actual instruction manual for using the device as well as hints as to how to exploit it and even write software for it.( Inspired by Shenzhen I/O’s manual )&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10-8-2022&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;VM can now read assembler source files and parse them into integer arrays&lt;/p&gt;

&lt;p&gt;Also the source files have the ability to define both byte strings and directly write bytes to the source file.&lt;/p&gt;

&lt;p&gt;VM can also compare registers and jump according to if an equal flag was set.&lt;/p&gt;

&lt;p&gt;Added some email correspondences and company forms for the company that designed the RX-500 (Mouseteck)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10-10-2022&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;VM can write to the display and recognizes jumps and labels&lt;/p&gt;

&lt;p&gt;Implemented basic system calls&lt;/p&gt;

&lt;p&gt;Print String, which reads a location in memory until a 0 is reached which is the end of a string&lt;/p&gt;

&lt;p&gt;Print Char which prints the given value as a character&lt;/p&gt;

&lt;p&gt;Flushed out the basic instruction set for the Rx-500 manual.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10-14-2022&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Modified the RX-500 project to run live parsed assembler code, subroutines, call and return instructions implemented&lt;/p&gt;

&lt;p&gt;&lt;code&gt;:sub-001&lt;br&gt;
loada 41&lt;br&gt;
loadb 70&lt;br&gt;
sys&lt;br&gt;
ret&lt;br&gt;
call sub-001&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/T4WqCNPv2pY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10-15-2022&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Added save and restore instructions to save the state of the registers when entering a subroutine.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;:sub-001&lt;br&gt;
save&lt;br&gt;
loada 55&lt;br&gt;
loadx printchar&lt;br&gt;
sys&lt;br&gt;
restore&lt;br&gt;
ret&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10-16-2022&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Started to write a graphics driver that would modify the pixel data of the screen directly.&lt;/p&gt;

&lt;p&gt;Also added a readkey system call&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The RX-500</title>
      <dc:creator>Mouseroot</dc:creator>
      <pubDate>Mon, 17 Oct 2022 07:04:14 +0000</pubDate>
      <link>https://dev.to/mouseroot/the-rx-500-4pmd</link>
      <guid>https://dev.to/mouseroot/the-rx-500-4pmd</guid>
      <description>&lt;p&gt;Imagine discovering a device, a handheld about the size of your standard iPhone, at a first glance it appears to be a game device of some kind, along with the device you discover a manual, its not super thick, but it has weight to it...you decide to turn the device on, you flip the switch and you hear the sound of the internal hard drives spinning up and the screen comes to life, the monochrome mini-CRT glows a familiar dark green as words start to pour over the screen some of it is understandable even for the layman however most of it appears to be random information that is unknown to the user.&lt;/p&gt;

&lt;p&gt;As you explore the device you see that it appears to be some kind of company device perhaps issued to employees of a company called mouseteck&lt;/p&gt;

&lt;p&gt;The manual seems to be a developers manual for writing software for the device as well information about how it was designed, including schematics and concepts used by developers to hot load software directly onto the device.&lt;/p&gt;

&lt;p&gt;What will you do with such a device? explore it? &lt;br&gt;
exploit it? &lt;br&gt;
write software for it? &lt;/p&gt;

&lt;p&gt;Who designed it? &lt;br&gt;
What is mouseteck? &lt;/p&gt;

&lt;p&gt;the adventure begins for the developer at heart, for beginners or advanced software engineers, the RX-500 is a black box of untold power and magick to explore, break or develop for.&lt;/p&gt;

</description>
      <category>unity3d</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
