Handling File IO is another popular topic in Wii Hombrew for obvious reasons and one that I've spent a significant amount of time on. I'm going to use this post demonstrate proper initialization and deinitialization of SD(HC) and USB devices in C. There are in fact quite a few different ways to do it but I've refined my personal methodology over years of carefully tweaking it and testing it in many apps.
Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts
Friday, January 7, 2011
Wednesday, March 3, 2010
Counting in bases: How to count in binary, hexadecimal, and more!
Awhile ago, I posted a tutorial explaining to someone how to count in hexadecimal. I've edited the tutorial a bit and am now posting the superior version exclusively on my blog. Enjoy!
The first step to understanding bases is figure out what base a number is part of. To do that, count how many numbers are in that number's number system.
If a number is not written in base 10 (Decimal), it should have a subscript saying what base it is in. Example: Binary should be written like this: 1010101011101002
Do you remember how they taught you to add in grammar (elementary for Americans like me) school? You used columns like the ones, tens, hundreds, thousands, etc. column. Like when you had a problem like the one below:
19
+3
-----
22
You were taught to add a one to the tens column after you exceeded the value of nine in the ones column. (You were also taught to add a one to the hundreds column after you exceeded a value of 9 in the tens column and so on and so forth). If you had for example, a 2 in the the ten;s column wit would have a value of 10 because 10*2=20. Likewise, that 9 in the example above has a value of 9 because 9*1=9. I guess you could say Number*ColumnValue=TrueValue. Most importantly, what I'm trying to do here is jog your memory of that 'columns system'.
Now consider this: How do you think the value of each column was determined?
The value of each column was determined by taking the base number (10 in our decimal system) and giving it an exponent of the column placement. Remember you move from right to left when doing this. Thus, the first column was the ones column because 10^0 is 1. The second column the tens column because 10^1 is 10. The third column the hundreds column because 10^2 is 100.
Now this column system I've finished fully describing applies to any base, just change the base number. So for binary (base 2), the first column is the one's column because 2^0 is 1. The second column is the two's column because 2^1 is 2. The third column is the four's column because 2^2 is 4. The fourth column is the eight's column because 2^3 is 8.
11112 (binary) is equivalent to 15 in decimal because (1*1)+(1*2)+(1*4)+(1*8)=15.
For hexadecimal (base 16) this application works the same way. The only thing that throws some people off about hexadecimal is the letters. Here's the hexadecimal to decimal conversion for them:
So now, finally, let's calculate the decimal value of a hexadecimal (base 16) number:
A35D16
First let's figure out the column values (Remember, we're working from right to left):
16^0 is 1 so the first column on the right is the one's column. The column next to it on the left is then the sixteens column. Then the two-hundred-fifty-six's column. Lastly on the far left we have the four-thousand-ninety-six's column.
So let's add it up:
(10*4096)+(3*256)+(5*16)+(13*1)=41821
If you understand all of this, you should now be able to count in any base be it base 2 binary, base 16 hex, or base 398 (whatever that's called). If not, read over the tutorial. I've truly made this as short and sweet as possible. Good luck :-)
If you have any questions regarding the content of this post, feel free to leave a comment, join me in #arikadosblog on EFNET, post in our forums, tweet to me, or send me an e-mail at castlevania7689@yahoo.com.
The first step to understanding bases is figure out what base a number is part of. To do that, count how many numbers are in that number's number system.
- Binary only has 2 characters in it: 0 and 1. Thus, binary is referred to as being a base 2 number system.
- Our Decimal system has 10 characters in it: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Thus, our decimal system is referred to as being in base 10.
- Hexadecimal has 16 characters in it: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Thus, hexadecimal is a base 16 number system.
If a number is not written in base 10 (Decimal), it should have a subscript saying what base it is in. Example: Binary should be written like this: 1010101011101002
Do you remember how they taught you to add in grammar (elementary for Americans like me) school? You used columns like the ones, tens, hundreds, thousands, etc. column. Like when you had a problem like the one below:
19
+3
-----
22
You were taught to add a one to the tens column after you exceeded the value of nine in the ones column. (You were also taught to add a one to the hundreds column after you exceeded a value of 9 in the tens column and so on and so forth). If you had for example, a 2 in the the ten;s column wit would have a value of 10 because 10*2=20. Likewise, that 9 in the example above has a value of 9 because 9*1=9. I guess you could say Number*ColumnValue=TrueValue. Most importantly, what I'm trying to do here is jog your memory of that 'columns system'.
Now consider this: How do you think the value of each column was determined?
The value of each column was determined by taking the base number (10 in our decimal system) and giving it an exponent of the column placement. Remember you move from right to left when doing this. Thus, the first column was the ones column because 10^0 is 1. The second column the tens column because 10^1 is 10. The third column the hundreds column because 10^2 is 100.
Now this column system I've finished fully describing applies to any base, just change the base number. So for binary (base 2), the first column is the one's column because 2^0 is 1. The second column is the two's column because 2^1 is 2. The third column is the four's column because 2^2 is 4. The fourth column is the eight's column because 2^3 is 8.
11112 (binary) is equivalent to 15 in decimal because (1*1)+(1*2)+(1*4)+(1*8)=15.
For hexadecimal (base 16) this application works the same way. The only thing that throws some people off about hexadecimal is the letters. Here's the hexadecimal to decimal conversion for them:
Hex -> Decimal A 10 B 11 C 12 D 13 E 14 F 15Before I move on with my lesson I want to point something out quick that's in huge relevance to digital circuitry and programming. The max value for one character of hex is 15. Thus, any one character in hex is equivalent to 4 characters in binary. If you don't fully understand why, take a look at that 1111 in base 2 equals 15 in base 10 example above again. Each binary character is actually called a bit in technological vernacular and each hex character is called a nibble. Two hex characters next to each other (AB for example) is called a byte.
So now, finally, let's calculate the decimal value of a hexadecimal (base 16) number:
A35D16
First let's figure out the column values (Remember, we're working from right to left):
16^0 is 1 so the first column on the right is the one's column. The column next to it on the left is then the sixteens column. Then the two-hundred-fifty-six's column. Lastly on the far left we have the four-thousand-ninety-six's column.
So let's add it up:
(10*4096)+(3*256)+(5*16)+(13*1)=41821
If you understand all of this, you should now be able to count in any base be it base 2 binary, base 16 hex, or base 398 (whatever that's called). If not, read over the tutorial. I've truly made this as short and sweet as possible. Good luck :-)
If you have any questions regarding the content of this post, feel free to leave a comment, join me in #arikadosblog on EFNET, post in our forums, tweet to me, or send me an e-mail at castlevania7689@yahoo.com.
Sunday, January 24, 2010
Writing a Randomized Bruteforce Attack in C/C++
The randomized bruteforce attack works by guessing possible passwords in a random order unlike the sequential bruteforce attacks which guesses passwords in a logical order.
Writing a randomized bruteforcer is very similar to writing a sequential bruteforcer. The only change in the attack is the password generation. For the password generation, in order to efficiently guess the password, you'll want to guess inside of a range character length. For example, if I was attacking someone, I would only try passwords between 6 and 8 characters in length since that is the average password size. Once you have the length decided upon and you have the location to attack specified, all thats left to do is generate and try passwords.
Below is a simple randomized bruteforce attack I wrote in C/C++:
Really, this attack is much simpler then the sequential bruteforce attacks and should be very easy for everyone to understand. One quick note about it, for demonstration purposes, it only guesses passwords as long as the one you input.
Writing a randomized bruteforcer is very similar to writing a sequential bruteforcer. The only change in the attack is the password generation. For the password generation, in order to efficiently guess the password, you'll want to guess inside of a range character length. For example, if I was attacking someone, I would only try passwords between 6 and 8 characters in length since that is the average password size. Once you have the length decided upon and you have the location to attack specified, all thats left to do is generate and try passwords.
Below is a simple randomized bruteforce attack I wrote in C/C++:
/*Change "(" to "<" and change ")" to ">" */
#include (iostream)
#include (string)
using namespace std;
/*Prototypes*/
void checkPassword(string password);
/*Globakl Variables*/
char chars[]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
string t;
/*This function checks to see if the generated password is correct*/
void checkPassword(string password) {
cout << "Trying this password: " << password << endl;
if (password==t) {
cout << "match [" << password << "]" << endl;
int pause;
cin >> pause;
exit(1);
}
}
int main() {
cout << "Enter a string (No more then 10 characters for demonstration purposes): " << endl;
cin >> t;
int passwordsize = t.length();
string basestring = "";
for(;;){
#include (iostream)
#include (string)
using namespace std;
/*Prototypes*/
void checkPassword(string password);
/*Globakl Variables*/
char chars[]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
string t;
/*This function checks to see if the generated password is correct*/
void checkPassword(string password) {
cout << "Trying this password: " << password << endl;
if (password==t) {
cout << "match [" << password << "]" << endl;
int pause;
cin >> pause;
exit(1);
}
}
int main() {
cout << "Enter a string (No more then 10 characters for demonstration purposes): " << endl;
cin >> t;
int passwordsize = t.length();
string basestring = "";
for(;;){
/*Generate and then check the password*/
for(int i=0;i
int chooseachar = rand() % 35 + 0;
basestring += chars[chooseachar];
}
checkPassword(basestring);
basestring = "";
}
return 0;
}
for(int i=0;i
int chooseachar = rand() % 35 + 0;
basestring += chars[chooseachar];
}
checkPassword(basestring);
basestring = "";
}
return 0;
}
Really, this attack is much simpler then the sequential bruteforce attacks and should be very easy for everyone to understand. One quick note about it, for demonstration purposes, it only guesses passwords as long as the one you input.
Labels:
bruteforcer,
C,
C++,
tutorial
Wednesday, January 20, 2010
Writing a Sequential Bruteforce Attack in C/C++
The bruteforce attack is simple enough to understand. It is performed by entering in every possible password that can be accepted by a system until the correct password is entered. However, actually writing one is a bit more complex. There's a complex underlying logic involved simply entering in every password. This post will cover the logic of programming a sequential bruteforcer and cap off with writing a sequential ascending bruteforcer in C/C++. Lastly, I will show a quick trick to turn the sequential ascending bruteforcer into a sequential descending bruteforcer.
A bruteforcer has three main logical components: A selection where the user inputs specific location of the attack; Generating the passwords to test; Testing the password.
Having the user input the specific location to attack is arguably the easiest part of writing a bruteforcer. This part can actually be "hard-coded" (specified by the programmer so no input is required) so I was thinking of not even mentioning it. But, I decided to bring it up as any bruteforcer meant to be used by more then one person will include this. Let's say we've written a bruteforcer that attacks Yahoo accounts. In this case, the bruteforcer will be programmed to attack Yahoo accounts, but the user must input the Yahoo account to specifically attack. This first component of the bruteforcer will handle thus handles obtianing this information.
Once the bruteforcer knows what it is going to attack, it must generate the password to try. In a sequential bruteforcer, the password tried each time will be sequentially one step away from the last password tried. So, in a sequential ascending bruteforcer, the bruteforcer will try the password 000001 followed by 000002. This works in reverse in a sequential descending bruteforcer. The programming of this is generally handled by writing a continuous loop which breaks only when the password generated is successful. Meanwhile, a handful of variables constantly increment with each run through the loop. When all of the possible passwords are tried, the variables are all reset as low as possible, the number of characters in the password is incremented or decremented, and the process begins again with checking all of the passwords one character longer or shorter then the last number of characters in a password. In practice, this is simpler then it sounds.
The last main component of a bruteforcer is the part in which a bruteforcer checks to see if it's generated the correct password. In some cases, this can surprisingly be the hardest part of the bruteforcer to write. Using our Yahoo example again, writing this part of the bruteforcer requires a knowledge of the Yahoo API. It's really hard for me to write how to perform the password check as each check will be written differently. While all checks are simple from a broad perspective, this is liable to get quite complex depending on what you're trying to bruteforce. My recommendation is to look for a library to do the check for you so you can do the least amount of work possible to perform what is really be a trivial step overall.
Here is the code I wrote to an ascending bruteforcer in C/C++. It's really rather small code and thus pretty self-explanatory. (The comments should help explain things too):
/*Change "(" to "<" and change ")" to ">" */
#include (iostream)
#include (string)
using namespace std;
/*Prototypes*/
void checkPassword(string password);
void recurse(int width, int position, string baseString);
/*Global Variables*/
char chars[]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
string t;
/*This function generates the password*/
void recurse(int width, int position, string baseString) {
for(int i=0;i<35;i++) {
if (position < width-1) {
recurse(width, position + 1, baseString+chars[i]);
}
checkPassword(baseString+chars[i]);
}
}
/*This function checks to see if the generated password is correct*/
void checkPassword(string password) {
cout << "Trying this password: " << password << endl;
if (password==t) {
cout << "match [" << password << "]" << endl;
int pause;
cin >> pause;
exit(1);
}
}
int main() {
cout << "Enter a string (No more then 10 characters for demonstration purposes): " << endl;
cin >> t;
int maxChars = 10;
for(int i=1;i
cout << "Checking passwords width [" << i << "]..." << endl;
recurse(i,0,"");
}
return 0;
}
To turn this into a sequential descending brutefrocer, make two small changes. Change the chars[] to equal: {'z','y','x','w','v','u','t','s','r','q','p','o','n','m','l','k','j','i','h','g','f','e','d','c','b','a','9','8','7','6','5','4','3','2','1','0'};
And lastly change the for loop in main() to:
for(int i = maxChars; i >0; i++) {
For those of you who still might not fully understand how all of the C/C++ works, I strongly encourage you to compile the bruteforcer program to further your study. I hope all of you reading this have found the subject of bruteforcers to be as fascinating as I find them to be.
A bruteforcer has three main logical components: A selection where the user inputs specific location of the attack; Generating the passwords to test; Testing the password.
Having the user input the specific location to attack is arguably the easiest part of writing a bruteforcer. This part can actually be "hard-coded" (specified by the programmer so no input is required) so I was thinking of not even mentioning it. But, I decided to bring it up as any bruteforcer meant to be used by more then one person will include this. Let's say we've written a bruteforcer that attacks Yahoo accounts. In this case, the bruteforcer will be programmed to attack Yahoo accounts, but the user must input the Yahoo account to specifically attack. This first component of the bruteforcer will handle thus handles obtianing this information.
Once the bruteforcer knows what it is going to attack, it must generate the password to try. In a sequential bruteforcer, the password tried each time will be sequentially one step away from the last password tried. So, in a sequential ascending bruteforcer, the bruteforcer will try the password 000001 followed by 000002. This works in reverse in a sequential descending bruteforcer. The programming of this is generally handled by writing a continuous loop which breaks only when the password generated is successful. Meanwhile, a handful of variables constantly increment with each run through the loop. When all of the possible passwords are tried, the variables are all reset as low as possible, the number of characters in the password is incremented or decremented, and the process begins again with checking all of the passwords one character longer or shorter then the last number of characters in a password. In practice, this is simpler then it sounds.
The last main component of a bruteforcer is the part in which a bruteforcer checks to see if it's generated the correct password. In some cases, this can surprisingly be the hardest part of the bruteforcer to write. Using our Yahoo example again, writing this part of the bruteforcer requires a knowledge of the Yahoo API. It's really hard for me to write how to perform the password check as each check will be written differently. While all checks are simple from a broad perspective, this is liable to get quite complex depending on what you're trying to bruteforce. My recommendation is to look for a library to do the check for you so you can do the least amount of work possible to perform what is really be a trivial step overall.
Here is the code I wrote to an ascending bruteforcer in C/C++. It's really rather small code and thus pretty self-explanatory. (The comments should help explain things too):
/*Change "(" to "<" and change ")" to ">" */
#include (iostream)
#include (string)
using namespace std;
/*Prototypes*/
void checkPassword(string password);
void recurse(int width, int position, string baseString);
/*Global Variables*/
char chars[]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
string t;
/*This function generates the password*/
void recurse(int width, int position, string baseString) {
for(int i=0;i<35;i++) {
if (position < width-1) {
recurse(width, position + 1, baseString+chars[i]);
}
checkPassword(baseString+chars[i]);
}
}
/*This function checks to see if the generated password is correct*/
void checkPassword(string password) {
cout << "Trying this password: " << password << endl;
if (password==t) {
cout << "match [" << password << "]" << endl;
int pause;
cin >> pause;
exit(1);
}
}
int main() {
cout << "Enter a string (No more then 10 characters for demonstration purposes): " << endl;
cin >> t;
int maxChars = 10;
for(int i=1;i
cout << "Checking passwords width [" << i << "]..." << endl;
recurse(i,0,"");
}
return 0;
}
To turn this into a sequential descending brutefrocer, make two small changes. Change the chars[] to equal: {'z','y','x','w','v','u','t','s','r','q','p','o','n','m','l','k','j','i','h','g','f','e','d','c','b','a','9','8','7','6','5','4','3','2','1','0'};
And lastly change the for loop in main() to:
for(int i = maxChars; i >0; i++) {
For those of you who still might not fully understand how all of the C/C++ works, I strongly encourage you to compile the bruteforcer program to further your study. I hope all of you reading this have found the subject of bruteforcers to be as fascinating as I find them to be.
Labels:
bruteforcer,
C,
C++,
tutorial
Monday, January 4, 2010
How to connect a Wiimote to your PC under Windows Vista or Windows 7
For those of you unaware, there are a ton of interesting projects floating around the old worldwide web involving wiimote hacking. While, to some people at least, it may not be quite as interesting as Wii homebrew; The notion of having your PC interact with Wii controllers is far too tantalizing an opportunity to pass up. Everyone should seriously try it at least once.
This post aims to provide the most clear and simple instructions available all across the internet of how to connect a Wiimote (the balance board and additional Wiimotes can also be connected the same way) to a PC running under Windows Vista or Windows 7. Regarding the choice of operating system for this post, I chose only to cover the operating systems which I've actually successfully done this on so far. I would assume connecting a Wiimote to a PC running Windows XP or perhaps even Windows 2000 would be nearly identical process. I am also currently playing with trying to get it to connect to my Ubuntu OS and will post a Linux version of this post when I do.
What you will need:
Now for the meat of this post: Connecting your Wiimote to your PC.
Windows Vista:
Now click Add which is located on the left side of the Bluetooth Devices window close to the bottom.
The Add Bluetooth Device Wizard appears!
Click the check box next to the phrase "My device is set-up and ready to be found."
Now press 1 and 2 on your Wiimote simultaneously.
While the LEDs along the bottom of your Wiimote are flashing, click Next in the Add Bluetooth Device Wizard.
This new screen of the wizard shows all of the Bluetooth devices within the range of your Bluetooth receiver. Click on Nintendo RVL-CNT-01 and then click Next.
In the next screen of the wizard, select the fourth option "Don't use a passkey". If your Wiimote has stopped blinking, press 1 and 2 simultaneously again and then click Next while the LEDs are still blinking.
Now click Finish to close the Add Bluetooth Device Wizard.
From now on, your Wiimote is connected to your PC. Your Wiimote only becomes unconnected when either end of the connection is broken. To break the connection, you will either have to remove your Wiimote's batteries, put your PC to sleep, or turn off your PC. Every time you want to connect your Wiimote to your PC, you will have to run through the process of adding a Bluetooth device again. Otherwise, whatever you are trying to use will not work. After you forget a few times and crash whatever program you're running that wants to use the Wiimote, I guarantee you that you will commit this simple little process to memory.
Now, before I end this post with you sitting at your computer screen with a nice connected Wiimote and nothing to do with it, let's run the Wiimote Data Visualizer program by Matthias Shapiro. To run the program, simply download it, unzip it, and then double-click the .exe file. You should be able to press buttons on your Wiimote and have your computer screen confirm that you are pressing them. You should also be able to read all of the other data being output by your Wiimote too. A quick final note before I send you off into the world Wiimote hacking, I linked to an older version of the Wiimote Data Visualizer program because I'm under the impression that is the most stable version of it. Later versions added the ability to see data from plug-in controllers (Nunchuk, Classic Controller, etc.) and even the Balance Board but I've read they don't work very well and crash often. Oh well :-(
If you have any questions regarding the content of this post, feel free to leave a comment, join me in #arikadosblog on EFNET, post in our forums, tweet to me, or send me an e-mail at castlevania7689@yahoo.com
This post aims to provide the most clear and simple instructions available all across the internet of how to connect a Wiimote (the balance board and additional Wiimotes can also be connected the same way) to a PC running under Windows Vista or Windows 7. Regarding the choice of operating system for this post, I chose only to cover the operating systems which I've actually successfully done this on so far. I would assume connecting a Wiimote to a PC running Windows XP or perhaps even Windows 2000 would be nearly identical process. I am also currently playing with trying to get it to connect to my Ubuntu OS and will post a Linux version of this post when I do.
What you will need:
- A PC running Windows Vista or Windows 7
- A Wiimote
- A Bluetooth adapter to read transmitted bluetooth signals if your PC cannot already do this
- Bluetooth technology installed on your PC (if your PC has an internal bluetooth reader or you have already set-up a bluetooth adapter, then this should already be installed)
Now for the meat of this post: Connecting your Wiimote to your PC.
Windows Vista:
- Go to Control Panel
- Click on Bluetooth Devices
- Go to Control Panel
- Click on Hardware and Sound
- Click on Devices and Printers
- Click on Bluetooth Devices
Now click Add which is located on the left side of the Bluetooth Devices window close to the bottom.
The Add Bluetooth Device Wizard appears!
Click the check box next to the phrase "My device is set-up and ready to be found."
Now press 1 and 2 on your Wiimote simultaneously.
While the LEDs along the bottom of your Wiimote are flashing, click Next in the Add Bluetooth Device Wizard.
This new screen of the wizard shows all of the Bluetooth devices within the range of your Bluetooth receiver. Click on Nintendo RVL-CNT-01 and then click Next.
In the next screen of the wizard, select the fourth option "Don't use a passkey". If your Wiimote has stopped blinking, press 1 and 2 simultaneously again and then click Next while the LEDs are still blinking.
Now click Finish to close the Add Bluetooth Device Wizard.
From now on, your Wiimote is connected to your PC. Your Wiimote only becomes unconnected when either end of the connection is broken. To break the connection, you will either have to remove your Wiimote's batteries, put your PC to sleep, or turn off your PC. Every time you want to connect your Wiimote to your PC, you will have to run through the process of adding a Bluetooth device again. Otherwise, whatever you are trying to use will not work. After you forget a few times and crash whatever program you're running that wants to use the Wiimote, I guarantee you that you will commit this simple little process to memory.
Now, before I end this post with you sitting at your computer screen with a nice connected Wiimote and nothing to do with it, let's run the Wiimote Data Visualizer program by Matthias Shapiro. To run the program, simply download it, unzip it, and then double-click the .exe file. You should be able to press buttons on your Wiimote and have your computer screen confirm that you are pressing them. You should also be able to read all of the other data being output by your Wiimote too. A quick final note before I send you off into the world Wiimote hacking, I linked to an older version of the Wiimote Data Visualizer program because I'm under the impression that is the most stable version of it. Later versions added the ability to see data from plug-in controllers (Nunchuk, Classic Controller, etc.) and even the Balance Board but I've read they don't work very well and crash often. Oh well :-(
If you have any questions regarding the content of this post, feel free to leave a comment, join me in #arikadosblog on EFNET, post in our forums, tweet to me, or send me an e-mail at castlevania7689@yahoo.com
Labels:
tutorial,
wii homebrew,
wiimote homebrew
Thursday, November 26, 2009
How to safely update your Wii to 4.2
Nintendo released the 4.2 firmware and it dealt a serious blow to Wii homebrew. It was also seen bricking some Wii consoles due to an update made to the Wiis boot2 process. The infamous Waninkoko as well as other coders have released programs which claim to safely update people to 4.2. However, you actually have a better of chance of these apps bricking you than Nintendo's boot2 update. This leads many people to believe that it is simply best to stay away from 4.2 However, this is not the case. You can safely update to 4.2 retaining all of your homebrew and avoiding the boot2 update. This post will show you how.
Disclaimer: Before going on, I would like to remind you that updating through Nintendo is not as risky as it seems. Even after updating through Nintendo, you can still retain all of your homebrew. However, in theory, the method I describe in this post does carry less of a risk.
First things first, use the latest hackmii installer to update to the latest versions of the Homebrew Channel, DVDX, and BootMii.
Now backup your NAND with BootMii. We will obviously be messing with the NAND a little bit, so it is best to have a backup incase something goes horribly wrong.
Before going on, you need an IOS with the trucha bug installed. If you do not have one, use the trucha bug restorer to install one.
Now, have my Dop-IOS MOD install IOS 61 and IOS 70 using your trucha bugged IOS.
Next, have my Dop-IOS MOD install System Menu 4.2 for your region.
Then, have my Dop-IOS MOD install the shop channel for your region.
Finally, use StartPatch (make sure you use the proper version for your region) to install hacks you think are a good ideas into your 4.2 system menu.
Congratulations, you have safely updated to 4.2! As a bonus, you can now do things on 4.2 normal 4.2 users can't.
If you have any questions regarding the content of this post, feel free to leave a comment, join me in #arikadosblog on EFNET, post in our forums, tweet to me, or send me an e-mail at castlevania7689@yahoo.com
Disclaimer: Before going on, I would like to remind you that updating through Nintendo is not as risky as it seems. Even after updating through Nintendo, you can still retain all of your homebrew. However, in theory, the method I describe in this post does carry less of a risk.
First things first, use the latest hackmii installer to update to the latest versions of the Homebrew Channel, DVDX, and BootMii.
Now backup your NAND with BootMii. We will obviously be messing with the NAND a little bit, so it is best to have a backup incase something goes horribly wrong.
Before going on, you need an IOS with the trucha bug installed. If you do not have one, use the trucha bug restorer to install one.
Now, have my Dop-IOS MOD install IOS 61 and IOS 70 using your trucha bugged IOS.
Next, have my Dop-IOS MOD install System Menu 4.2 for your region.
Then, have my Dop-IOS MOD install the shop channel for your region.
Finally, use StartPatch (make sure you use the proper version for your region) to install hacks you think are a good ideas into your 4.2 system menu.
Congratulations, you have safely updated to 4.2! As a bonus, you can now do things on 4.2 normal 4.2 users can't.
If you have any questions regarding the content of this post, feel free to leave a comment, join me in #arikadosblog on EFNET, post in our forums, tweet to me, or send me an e-mail at castlevania7689@yahoo.com
Labels:
tutorial,
wii homebrew
Sunday, November 22, 2009
A thorough explanation of IOS and cIOS for everyone
We all remember when we first hacked our Wii. It was a fairly straightforward process. Crash your Wii, run some magic code (called a boot.elf) and install a magic channel that will let you run any and as much code as you want (homebrew applications or apps).
Eventually, we began reading more and more about the cool Wii homebrew applications and we began to read about these things they used called IOSs and cIOSs. Often we would see, "You must have a cIOS 249 installed to use this app" or "You must have an IOS that accepts fakesigning", and most common recently, "No vulnerable IOS found. For security reasons, we will not use an IOS that accepts fakesigning."
This post is intended to be a thorough explanation of what IOSs are, how they work, and what a cIOS is. Anyone, at any experience level (except for the hackmii l33t) should learn something here.
I feel the best way to start explaining IOSs is to take a trip through Wii homebrew history. Back when Hackmii developed the twilight hack, coders and users alike suddenly had the ability to create and run unsigned (or unofficial, ie: "homebrew") code on their Nintendo Wiis. However, it was undoubtedly very inconvenient to have to run The Legend of Zelda: Twlight Princess and crash it every single time you wanted to run one piece of code on your Wii. So Hackmii went to work creating a channel that you could access right from your Wii and run homebrew code with. In fact, this channel would even be able to run multiple pieces of code in a single use.
To install a channel, Hackmii went to work figuring out channels were installed naturally by the Wii. It was discovered that the Wii relies on an underlying system called IOS to do just that and more. The Wii contains multiple IOSs inside of it which are used for different purposes, but contain the same basic functions. In fact there is room in the Wii for 255 different IOSs. There is one IOS for the system menu, another IOS for games to use, and yet even another IOS for some channels to use. However, no more than IOS is ever running at once.
It was determined shortly afteraward that each IOS is made up of a set of low level functions, or code routines. Wii programs (games, channels, the system menu, etc.) called on the functions inside IOS to do things. If this reminds of you Linux kernels, you're thinking along the right path. IOSs basically are here to perform the same role for Wii that kernels perform for Linux.
One of the functions of IOSs is the ability to install content. This installable content, of course, included channels. In order to install a channel you needed two security keys.
The first key, the common key, was hidden inside each Wii on a ROM next to the starlet coprocessor. The common key is the same in each Nintendo Wii. In order to obtain it, Hackmii used a pair of tweezers in a tweezer attack (this is where the name team twiizers comes from) to complete a circuit, creating a serial line of communication to sniff (view the contents of) the RAM where the common key is stored while it is being used. And so, the firs tof two keys, the common key, was discovered: EBE42A225E8593E448D9C5457381AAF7 (base 16)
The second key, the private key, is stored only on Nintendo's servers. There is literally no way to obtain it from our client end except to attempt to bruteforce it (guess it again and again until we guess right). However, after staring at disassembles of IOSs for countless hours, hackmii realized that each IOS had a bug in their security. To check for the presence of the private key, the IOSs used strncmp(). strncmp() is a C function which checks to see if two strings are the same. If a null byte is detected, it is assumed that the strings are the same. So, in order to install a piece of content, we pass the common key and a null byte into IOSs content installation function. The method of installing content using a null byte instead of the private key is called fakesigning. The bug found in IOS (the usage of strncmp() as opposed to, say, memcmp() ) is called the trucha bug.
To summarize so far: In order to install content onto the Wii, the IOS you have running in the background must contain the trucha bug.
Later down the line, Nintendo would begin updating IOSs by fixing the trucha bug. Most likely, they did so by replacing the strncmp() check with a check like memcmp() which wouldn't terminate after the discovery of a null byte. Hackmii came up with a piece of code called patchmii to download the new IOSs and install the trucha bug into them. IOSs that have had the trucha bug patched into them are called cIOSs.
tona was the first programmer to release an application which downloaded an IOS (IOS 36 actually), patched it (making it a cIOS), and installed it as a different IOS (IOS 249 actually). Thus, cIOS 249 was created.
Other programmers have since replicated the feat. Waninkoko in conjunction with WiiGator have a cIOS installer which applies the trucha bug and other patches to an IOS (IOS 36 I believe) and install it as IOS 249. The patches in the cIOS beyond the inclusion of the trucha bug are patches to allow pirated games to be played. This has made cIOS 249 the "warez IOS" and is Nintendo's primary concern. I could give a you spiel about how this IOS appears to be inflated with inefficient code and how a lot of what's in it doesn't actually work like it claims to, but that's for another post.
So now I've walked you through what IOSs and cIOSs are by showing you the history of them. Hopefully, you should fully understand their purpose and be able to better understand what homebrew is talking about when it references them.
If you have any questions regarding the content of this post, feel free to leave a comment, join me in #arikadosblog on EFNET, post in our forums, tweet to me, or send me an e-mail at castlevania7689@yahoo.com
Eventually, we began reading more and more about the cool Wii homebrew applications and we began to read about these things they used called IOSs and cIOSs. Often we would see, "You must have a cIOS 249 installed to use this app" or "You must have an IOS that accepts fakesigning", and most common recently, "No vulnerable IOS found. For security reasons, we will not use an IOS that accepts fakesigning."
This post is intended to be a thorough explanation of what IOSs are, how they work, and what a cIOS is. Anyone, at any experience level (except for the hackmii l33t) should learn something here.
I feel the best way to start explaining IOSs is to take a trip through Wii homebrew history. Back when Hackmii developed the twilight hack, coders and users alike suddenly had the ability to create and run unsigned (or unofficial, ie: "homebrew") code on their Nintendo Wiis. However, it was undoubtedly very inconvenient to have to run The Legend of Zelda: Twlight Princess and crash it every single time you wanted to run one piece of code on your Wii. So Hackmii went to work creating a channel that you could access right from your Wii and run homebrew code with. In fact, this channel would even be able to run multiple pieces of code in a single use.
To install a channel, Hackmii went to work figuring out channels were installed naturally by the Wii. It was discovered that the Wii relies on an underlying system called IOS to do just that and more. The Wii contains multiple IOSs inside of it which are used for different purposes, but contain the same basic functions. In fact there is room in the Wii for 255 different IOSs. There is one IOS for the system menu, another IOS for games to use, and yet even another IOS for some channels to use. However, no more than IOS is ever running at once.
It was determined shortly afteraward that each IOS is made up of a set of low level functions, or code routines. Wii programs (games, channels, the system menu, etc.) called on the functions inside IOS to do things. If this reminds of you Linux kernels, you're thinking along the right path. IOSs basically are here to perform the same role for Wii that kernels perform for Linux.
One of the functions of IOSs is the ability to install content. This installable content, of course, included channels. In order to install a channel you needed two security keys.
The first key, the common key, was hidden inside each Wii on a ROM next to the starlet coprocessor. The common key is the same in each Nintendo Wii. In order to obtain it, Hackmii used a pair of tweezers in a tweezer attack (this is where the name team twiizers comes from) to complete a circuit, creating a serial line of communication to sniff (view the contents of) the RAM where the common key is stored while it is being used. And so, the firs tof two keys, the common key, was discovered: EBE42A225E8593E448D9C5457381AAF7 (base 16)
The second key, the private key, is stored only on Nintendo's servers. There is literally no way to obtain it from our client end except to attempt to bruteforce it (guess it again and again until we guess right). However, after staring at disassembles of IOSs for countless hours, hackmii realized that each IOS had a bug in their security. To check for the presence of the private key, the IOSs used strncmp(). strncmp() is a C function which checks to see if two strings are the same. If a null byte is detected, it is assumed that the strings are the same. So, in order to install a piece of content, we pass the common key and a null byte into IOSs content installation function. The method of installing content using a null byte instead of the private key is called fakesigning. The bug found in IOS (the usage of strncmp() as opposed to, say, memcmp() ) is called the trucha bug.
To summarize so far: In order to install content onto the Wii, the IOS you have running in the background must contain the trucha bug.
Later down the line, Nintendo would begin updating IOSs by fixing the trucha bug. Most likely, they did so by replacing the strncmp() check with a check like memcmp() which wouldn't terminate after the discovery of a null byte. Hackmii came up with a piece of code called patchmii to download the new IOSs and install the trucha bug into them. IOSs that have had the trucha bug patched into them are called cIOSs.
tona was the first programmer to release an application which downloaded an IOS (IOS 36 actually), patched it (making it a cIOS), and installed it as a different IOS (IOS 249 actually). Thus, cIOS 249 was created.
Other programmers have since replicated the feat. Waninkoko in conjunction with WiiGator have a cIOS installer which applies the trucha bug and other patches to an IOS (IOS 36 I believe) and install it as IOS 249. The patches in the cIOS beyond the inclusion of the trucha bug are patches to allow pirated games to be played. This has made cIOS 249 the "warez IOS" and is Nintendo's primary concern. I could give a you spiel about how this IOS appears to be inflated with inefficient code and how a lot of what's in it doesn't actually work like it claims to, but that's for another post.
So now I've walked you through what IOSs and cIOSs are by showing you the history of them. Hopefully, you should fully understand their purpose and be able to better understand what homebrew is talking about when it references them.
If you have any questions regarding the content of this post, feel free to leave a comment, join me in #arikadosblog on EFNET, post in our forums, tweet to me, or send me an e-mail at castlevania7689@yahoo.com
Labels:
tutorial,
wii homebrew,
wii homebrew development
Saturday, November 7, 2009
Googlecode SVN and Tortoise Tutorial
Ever since I set-up two svns of my own on googlecode, I've recieved a ton of questions about SVNs and how to use them ranging from the most basic to the most complex. I apologize that I haven't been able to individually respond the unprecedented amount of messages I've recieved, so this post will aim to be a rather lengthresponse to all of them. So lets get started shall we?
What is an SVN?
"Subversion is a free/open-source version control system. That is, Subversion manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data, or examine the history of how your data changed. In this regard, many people think of a version control system as a sort of “time machine”."--svnbook
In my own words, think of an SVN as a landfill. Every now and then the garbage trucks (coders) come in and dump their garbage into the landfill. At any point, anyone can visit the landfill and view the garbage that was dropped off at any day. If they want to, they can even take an exact copy of any of the garbage home with them. Thus, people can compare garbage dropped off at different days and seek to understand why the garbage one day is different than the day before it, or attempt to improve the garbage collection by adding some garbage of their own to produce a more ripe smell. Now think of the garbage as code and you'll figure out the picture of what an SVN is supposed to do.
Why Googlecode?
Because Googlecode securely hosts your SVN online for free for the world to view. Googlecode also allows you to have a wiki and an issue tracker for you project to help you help your fans and maintain your code respectively.
How do I access/use an SVN?
You use an SVN by performing basic commands upon it which I will cover here. Generally, people use an SVN client, or a computer program to perform these SVN commands for them. The two most popular are RapidSVN and Tortoise SVN.
Import: Upload a new project to an SVN
Commit: Upload new versions of existing files onto an SVN
Add: Add a file to an SVN
Delete: Remove a file from an SVN
Checkout: Download an entire SVN
Why Tortoise?
Most SVN clients are command line programs. In colloquial terms, this means that they require you input long strings of text into an ugly console window to get something to work. Tortoise is a nice looking shell extension. This means that you can perform basic SVN maintenance by simply right-clicking.
And finally, a tutorial on how to set-up and run your own SVN with Googlcode and Tortoise:
1)Create an account with Googlecode
2)Create an SVN on Googlecode on the create project page. Be sure to use a subversion set-up instead of a mercucial one.
3)Install Tortoise SVN
4)Right-click on the main folder for the project you want to upload to your SVN and select import
5)You will be prompted to enter some information. Your username is your Googlecode account name and your password is the security code found in your Googlecode profile settings.
6)Delete your project from your computer
7)Right-click and checkout your SVN
8)From now on, right-click your project's main folder and commit after you make any changes to your project to upload a new revision of your project to the SVN.
9)Stop reading this guide. Your done. Congratulations!!!
Sunday, October 25, 2009
Dual and Multi Boot Operating Systems
Did you know it's possible to have more than one operating system installed on your computer? In fact, some people have three or even more operating systems installed. Having two operating systems installed on your computer is called having a dual boot operating system. Having more than two operating systems installed on your computer is called having a multi boot operating system.
There are many advantages to having more than one operating system installed on your computer.
Foremost, it makes your computer compatible with a wider variety of programs. Since computer programs only work on the operating system they were compiled for, having another operating system ready to go means that you can launch a lot more computer programs than you could without one.
Another advantage to having more than one operating system installed is security (also called "insurance" by some people). Should something ever happen to one of your operating systems, it's possible that you may be able to use one of your other operating systems to fix whatever went wrong with your broken operating system. For example, you could use a Linux operating system to fix a corrupted file preventing a Windows or MAC operating system from launching.
Before I go any further with this post, I wanted to quickly point out that it is possible to have multiple versions of an operating system installed on any computer. For example, you can have Windows Vista and Windows XP and Windows 7 all installed on the same machine. Likewise, you can do the same with different versions of MAC or Linux operating systems if you wish to.
Installing another operating system is as simple as installing your first operating system. You run the operating system installer (which is usually a disc you put into your computer before turning your computer on) and tell the install to install your designated operating system into partitioned space not used by any other operating system. For example, your Windows 7 installation takes up a partition of 250GB on your 500GB hardrive so you choose to install Ubuntu Linux on a partition of 100GB of the remaining 250GB. From then on, every time you turn on your computer, you'll be asked which operating system you'd like to boot into.
There are many advantages to having more than one operating system installed on your computer.
Foremost, it makes your computer compatible with a wider variety of programs. Since computer programs only work on the operating system they were compiled for, having another operating system ready to go means that you can launch a lot more computer programs than you could without one.
Another advantage to having more than one operating system installed is security (also called "insurance" by some people). Should something ever happen to one of your operating systems, it's possible that you may be able to use one of your other operating systems to fix whatever went wrong with your broken operating system. For example, you could use a Linux operating system to fix a corrupted file preventing a Windows or MAC operating system from launching.
Before I go any further with this post, I wanted to quickly point out that it is possible to have multiple versions of an operating system installed on any computer. For example, you can have Windows Vista and Windows XP and Windows 7 all installed on the same machine. Likewise, you can do the same with different versions of MAC or Linux operating systems if you wish to.
Installing another operating system is as simple as installing your first operating system. You run the operating system installer (which is usually a disc you put into your computer before turning your computer on) and tell the install to install your designated operating system into partitioned space not used by any other operating system. For example, your Windows 7 installation takes up a partition of 250GB on your 500GB hardrive so you choose to install Ubuntu Linux on a partition of 100GB of the remaining 250GB. From then on, every time you turn on your computer, you'll be asked which operating system you'd like to boot into.
Friday, October 23, 2009
A Basic Explanation of Operating Systems
Computer hardware is important and all, but everyone knows that operating systems are the most essential piece of a computer. A computer operating system is the main piece of software that runs a computer. The purpose of an operating system is to let you launch and use programs on your computer. Generally, operating systems come with their own set of programs already installed so you can browse the internet, explore your file system, and play media files from the get-go.
The three most widely used operating systems (which I'll cover in more detail later in this post) are:
MAC is a commercial operating system developed by Apple. MAC operating systems are unique in that they can only be installed on computers manufactured and condoned by Apple. MAC operating systems come supplied with an unrivaled set of photo and video editing software. MAC users tend to argue that the monopolistic hardware situation is worth the cheaper price and the MAC operating system. Most interesting about the MAC platform (for programmers only, really) is that MAC computers come with an SDK which allows people to develop for any device (including iPhone) that's part of the MAC platform. The latest version of the MAC operating system is MAC OS X.
Linux is a free, open source operating system core. Developers then use the core to create their own distributions (also known as versions or distros) of the linux operating system. The two most popular distros are Ubuntu and Arch. Because linux operating systems are free, they can save you a signifigant chunk of money when you are building your own PC. Many people say that the linux operating systems rival and in many cases even surpass the quality of the commercial operating systems.
Every computer needs an operating system to perfrom the most rudimentary tasks and we are fortunate to live at a time with so many different choices of operating systems.
The three most widely used operating systems (which I'll cover in more detail later in this post) are:
- Windows
- MAC
- Linux
MAC is a commercial operating system developed by Apple. MAC operating systems are unique in that they can only be installed on computers manufactured and condoned by Apple. MAC operating systems come supplied with an unrivaled set of photo and video editing software. MAC users tend to argue that the monopolistic hardware situation is worth the cheaper price and the MAC operating system. Most interesting about the MAC platform (for programmers only, really) is that MAC computers come with an SDK which allows people to develop for any device (including iPhone) that's part of the MAC platform. The latest version of the MAC operating system is MAC OS X.
Linux is a free, open source operating system core. Developers then use the core to create their own distributions (also known as versions or distros) of the linux operating system. The two most popular distros are Ubuntu and Arch. Because linux operating systems are free, they can save you a signifigant chunk of money when you are building your own PC. Many people say that the linux operating systems rival and in many cases even surpass the quality of the commercial operating systems.
Every computer needs an operating system to perfrom the most rudimentary tasks and we are fortunate to live at a time with so many different choices of operating systems.
Monday, October 19, 2009
A Very Basic Explanation of how Computers Work
The computer is easily the most important object in the modern day. Whether it's a PC, MAC, iPod, Nintendo Wii, or even a PS3, all computers operate in the same manner. Unfortunately, the average consumer doesn't understand even the purpose of the most basic components of a computer. So with the new computer and laptop model releases right around the corner (I'm picking up my first computer in less than a week!!!) I figured it would be appropriate for me to write out a very basic explanation of how every computer works.
While writing this, I'm going to keep two very important things in mind. First, long explanations are boring and unnecessary. Second, I need to write from the point of view of someone who knows absolutely nothing about computers. So let's get to it!
All computers are made up of the same basic components which interact with one another to perform the overall function of making the computer work. These parts are:
The processor is the "brain" of the computer. The processor reads and executes all of the code it receives. The faster your processor is, the faster things happens. The more cores your processor has, the more information it can simultaneously process (again, the faster it can go).
The random access memory (RAM) of a computer temporarily holds information the computer needs. For example, your computer's RAM is currently holding your entire internet browser. While information is held in the RAM, the processor can more quickly access it. My dad has a simple explanation of why more RAM is better which I'll quote here: "The more RAM your computer has, the more computer programs you can have running at a good speed at once."
The hard drive is the storage unit of the computer. All of your save files, mp3s, videos, and pictures are stored on the hard drive to be accessed when the computer wants them (ie: When you tell the computer to get them)
The video and sound cards of a computer are parts that output video and sound signals to the monitor and speakers respectively.
All of these different parts work in unison in every computer to provide a user friendly experience. This explanation was aimed at being an extremely simple "ground level" explanation of how computers work so everyone is starting at the same the level for when I get more into how computers work later.
While writing this, I'm going to keep two very important things in mind. First, long explanations are boring and unnecessary. Second, I need to write from the point of view of someone who knows absolutely nothing about computers. So let's get to it!
All computers are made up of the same basic components which interact with one another to perform the overall function of making the computer work. These parts are:
- The motherboard
- The processor
- The RAM
- The hard drive
- The video and sound cards
The processor is the "brain" of the computer. The processor reads and executes all of the code it receives. The faster your processor is, the faster things happens. The more cores your processor has, the more information it can simultaneously process (again, the faster it can go).
The random access memory (RAM) of a computer temporarily holds information the computer needs. For example, your computer's RAM is currently holding your entire internet browser. While information is held in the RAM, the processor can more quickly access it. My dad has a simple explanation of why more RAM is better which I'll quote here: "The more RAM your computer has, the more computer programs you can have running at a good speed at once."
The hard drive is the storage unit of the computer. All of your save files, mp3s, videos, and pictures are stored on the hard drive to be accessed when the computer wants them (ie: When you tell the computer to get them)
The video and sound cards of a computer are parts that output video and sound signals to the monitor and speakers respectively.
All of these different parts work in unison in every computer to provide a user friendly experience. This explanation was aimed at being an extremely simple "ground level" explanation of how computers work so everyone is starting at the same the level for when I get more into how computers work later.
Friday, August 14, 2009
Programming with the Balance Board
This post covers how to program with the balance board via devkitPRO's libogc.
But before we program the Wii Balance Board, we should understand how the board itself works. The balance board has four sensors in it which can detect pressure applied to them. The sensors will be referred to in this post as the top left sensor, the bottom left sensor, the top right sensor, and the bottom right sensor. Unlike Wiimotes which can be set to one of four channels, the balance board is always automatically set to a fifth channel.
devkitPRO reads the data from this board initially as raw interpolated data from each sensor. To the untrained eye, this data looks like a bunch of random numbers. devkitPRO then applies a formula to the raw interpolated data and can determine the approximate amount of pressure applied to any of the four sensors. devkitPRO also calculates an X and Y coordinate based on the difference in data between all of the sensors. As programmer's, we have access to all of this data at any time we wish.
So now that we have a basic overview of how the balance board works and how devkitPRO interprets the data read from it, let's get straight to the actual programming:
First, include the balance board code from devkitPRO:
#include (wiiuse/wpad.h)//replace "(" with "<" and ")" with ">"
Initialize the balance board:
struct expansion_t exp;
exp.type = WPAD_EXP_WIIBOARD;
For every turn of a loop that needs to access data from the balance board, be sure to have the computer read the data coming from the balance board:
WPAD_ScanPads();
WPAD_Expansion(WPAD_BALANCE_BOARD, &exp);
You'll then have access to the following values from the expansion_t struct exp:
How you use these values is entirely up to you. I highly reccomend basing the majority of your code around the X and Y values if possible. I'd now like to elaborate on how these values are used:
Hopefully this post gave you a good introduction on how to program with the Wii Balance Board. Finding the right way to use the values from the balance board is mostly up to how you interpret the specific needs of your program.
Kudos to Ave who originally wrote a patch that implemented the balance board in libogc. Without you, this tutorial wouldn't exist.
But before we program the Wii Balance Board, we should understand how the board itself works. The balance board has four sensors in it which can detect pressure applied to them. The sensors will be referred to in this post as the top left sensor, the bottom left sensor, the top right sensor, and the bottom right sensor. Unlike Wiimotes which can be set to one of four channels, the balance board is always automatically set to a fifth channel.
devkitPRO reads the data from this board initially as raw interpolated data from each sensor. To the untrained eye, this data looks like a bunch of random numbers. devkitPRO then applies a formula to the raw interpolated data and can determine the approximate amount of pressure applied to any of the four sensors. devkitPRO also calculates an X and Y coordinate based on the difference in data between all of the sensors. As programmer's, we have access to all of this data at any time we wish.
So now that we have a basic overview of how the balance board works and how devkitPRO interprets the data read from it, let's get straight to the actual programming:
First, include the balance board code from devkitPRO:
#include
Initialize the balance board:
struct expansion_t exp;
exp.type = WPAD_EXP_WIIBOARD;
For every turn of a loop that needs to access data from the balance board, be sure to have the computer read the data coming from the balance board:
WPAD_ScanPads();
WPAD_Expansion(WPAD_BALANCE_BOARD, &exp);
You'll then have access to the following values from the expansion_t struct exp:
exp.wb.tl - The approximate pressure on the top left sensor exp.wb.tr - The approximate pressure on the top right sensor exp.wb.bl - The approximate pressure on the bottom left sensor exp.wb.br - The approximate pressure on the bottom right sensor exp.wb.rtl - The raw data from the top left sensor exp.wb.rtr - The raw data from the top right sensor exp.wb.rbl - The raw data from the bottom left sensor exp.wb.rbr - The raw data from the bottom right sensor exp.wb.x - The calculated X value exp.wb.y - The calculated Y value
How you use these values is entirely up to you. I highly reccomend basing the majority of your code around the X and Y values if possible. I'd now like to elaborate on how these values are used:
If X is less than 0, then there is more pressure on the left half of the board If X is greater than 0, then there is more pressure on the right half of the board If Y is less than 0, then there is more pressre on the top half of the board If Y is greater than 0, then there is more pressure on the bottom half of the board
Hopefully this post gave you a good introduction on how to program with the Wii Balance Board. Finding the right way to use the values from the balance board is mostly up to how you interpret the specific needs of your program.
Kudos to Ave who originally wrote a patch that implemented the balance board in libogc. Without you, this tutorial wouldn't exist.
Labels:
tutorial,
wii homebrew development
Monday, August 3, 2009
Everything About the Shoutbox
The purpose of this post is completely explain (in great detail) how the Shoutbox on the right side of the page underneath the "Get Help Directly From Arikado" gadget works:
How to use the Shoutbox
Using the Shoutbox is simple. Enter a name in the box that says "Name" and enter what you want to say in the box that says "Message". Then click send or press ENTER on your keyboard and your message will appear in the shoutbox immediately.
To register your chosen nickname so no one else can use it, press the "+" button and then enter in the nickname you would like to register and a password for it. You can then use the "+" button to log in under your registered nickname.
The Shoutbox is a dynamic element meaning that you do not have to refresh the page you are on to see your posted message appear or to see messages posted by other users.
To enlarge the Shoutbox, you can click on the white underlined text at the top of it that says "Shoutbox".
To register your chosen nickname so no one else can use it, press the "+" button and then enter in the nickname you would like to register and a password for it. You can then use the "+" button to log in under your registered nickname.
The Shoutbox is a dynamic element meaning that you do not have to refresh the page you are on to see your posted message appear or to see messages posted by other users.
To enlarge the Shoutbox, you can click on the white underlined text at the top of it that says "Shoutbox".
Rules
- The rules are subject change.
- No spamming.
- No links to vulgar imagery.
- No exceptionally vulgar language.
The Shoutbox User Permission Power Levels
Admins are people with the power to delete messages left by users and IP Ban users with the single click of the mouse. They can also grant or take away moderation and/or administrative privileges. They are the top level people who can use the Shoutbox. Moderators can only become Admins if the owner of the Shoutbox appoints them to be an Admin.
Moderators can delete comments left by users and view the IP addresses of everyone using the Shoutbox. They can forward IP addresses to Admins so Admins can ban users if the Admins see fit. Users can only become Moderators if an Admin appoints them to be a Moderator.
Users are people with registered nicknames who can leave messages in the Shoutbox. You can become a User simply by registering a nickname.
Guests are users with unregistered nicknames who can leave messages in the Shoutbox and are infamously subjected to being treated poorly by other Users until they register their nicknames and become Users. Everyone is a guest by default until they register a nickname.
Moderators can delete comments left by users and view the IP addresses of everyone using the Shoutbox. They can forward IP addresses to Admins so Admins can ban users if the Admins see fit. Users can only become Moderators if an Admin appoints them to be a Moderator.
Users are people with registered nicknames who can leave messages in the Shoutbox. You can become a User simply by registering a nickname.
Guests are users with unregistered nicknames who can leave messages in the Shoutbox and are infamously subjected to being treated poorly by other Users until they register their nicknames and become Users. Everyone is a guest by default until they register a nickname.
List of all Registered People who use the Shoutbox
Admins
Arikado
Moderators
Pinball Wizard
Users
Profetlyn
Arikado
Moderators
Pinball Wizard
Users
Profetlyn
Tuesday, July 21, 2009
How to Output Text from Fonts with libwiisprite
Every good programmer knows that they can make their programs look better than they really are ( ;-) ) by printing their text using a High Quality Font. It's even better when you can change the color of that font on demand. Changing the font size on demand can produce some beautiful artistic designs too. All of this can be used to make a higher quality, more "polished" program.
Unfortunately, libwiisprite is the only of the three major libraries (the other two being GRRLIB and libwiigui) that can't output, or print, text using characters taken from a font. And while libwiisprite can't do this by itself, it doesn't mean we can't combine a few additional libraries to our program to do it ourself. This post will show you step-by-step how to get your programs that use libwiisprite to output text from a font.
The first thing we need to do is set up our enviroment. First lets go here and download and set up the FreeTypeGX Library. Carefully follow the instructions on the page to set up the library. Once you have FreeTypeGX set up and installed, go here and download the ftimage library. You can install it by placing the .h files in devkitPRO's "include" directory (or 'folder' for those of you that prefer Windows terminology) and the .a file in devkitPRO's "libs" directory.
Now let's set up the directory that the program we're making is set up in. (The path is probably something like C:/projects/wii/nameofyourproject In the directory for your program, you should have a directory named "data". If not, make one now. In "data" we will place the font that we want to use. Any font will do as long as it is in .ttf or .otf format.
Now, let's set up the makefile of our prgoram. First, add -lfreetype and -lftimage under LIBS: Then, add a rule for compiling your font. If you're using the .ttf font format, your rule will look like this:
Finally, let's get to writing the meat of the program. First, include these two lines of code wherever necessary:
#include "ftImage.h" //The ftimage library
#include "namefthefontinthedatafolder_ttf.h" //Font being used (you have it in the data folder)
Now, wherever appropriate, declare these two objects:
ftImage print(640, 480); //This will store the string of text we print
Sprite Text; //This Sprite will be used to render the ftImage member print
Now, this little snippet of code is all we need to prepare our objects to store and render text:
print.setFont(fthenameofthefontinthedatafolder_ttf, thenameofthefontinthedatafolder_ttf_size);//Set the font we are using
print.setSize(32);//Set the size of the font (should be a multiple of 4)
print.setColor(Color::Color(255,40,40));//Set the color of the font in RGB format
Text.SetPosition(100, 50);//Set the position of the starting point of the text we will print
Text.SetImage(&print);//Append print as the image stored by Text
You do not need to use the above code in the order that I did. You can also feel free to change the values used by it at anytime during the course of your program.
And finally, here's how we render text:
print.printf(" Hellow World!\n");//Set the string of text to be rendered (escape characters can be use to render more than one line)
print.flush();//Tell the computer that the string of text is ready
Text.Draw();//Render the text
print.clear();//Clear the stored string of text
print.reset();//Bring us back to the render starting point (defined by Text.SetPosisition())
You'll want to use all of that above code in every loop that render text. If you render text without calling clear() and reset(), the next time you render text; you will render the same text as last time plus the new text you want to render.
Because I love pastie.org so much, For your convenience I have pastied all of the code used in this post for you to view here since blogger doesn't format everything perfectly.
Thanks to ArminTamazarian for whom without FreeTypeGX, this guide would never have been possible. Thanks to my good friend Ave for whom without ftimage, this guide would also never have been possible. Thanks Ave, for also being a good friend and helping me with tons of stuff at the drop of a hat. I'd never be where I am today without you.
Unfortunately, libwiisprite is the only of the three major libraries (the other two being GRRLIB and libwiigui) that can't output, or print, text using characters taken from a font. And while libwiisprite can't do this by itself, it doesn't mean we can't combine a few additional libraries to our program to do it ourself. This post will show you step-by-step how to get your programs that use libwiisprite to output text from a font.
The first thing we need to do is set up our enviroment. First lets go here and download and set up the FreeTypeGX Library. Carefully follow the instructions on the page to set up the library. Once you have FreeTypeGX set up and installed, go here and download the ftimage library. You can install it by placing the .h files in devkitPRO's "include" directory (or 'folder' for those of you that prefer Windows terminology) and the .a file in devkitPRO's "libs" directory.
Now let's set up the directory that the program we're making is set up in. (The path is probably something like C:/projects/wii/nameofyourproject In the directory for your program, you should have a directory named "data". If not, make one now. In "data" we will place the font that we want to use. Any font will do as long as it is in .ttf or .otf format.
Now, let's set up the makefile of our prgoram. First, add -lfreetype and -lftimage under LIBS: Then, add a rule for compiling your font. If you're using the .ttf font format, your rule will look like this:
#---------------------------------------------------------------------------------
# This rule links in binary data with the .ttf extension
#---------------------------------------------------------------------------------
%.ttf.o : %.ttf
#---------------------------------------------------------------------------------
@echo $(notdir $<) $(bin2o) -include $(DEPENDS)
# This rule links in binary data with the .ttf extension
#---------------------------------------------------------------------------------
%.ttf.o : %.ttf
#---------------------------------------------------------------------------------
@echo $(notdir $<) $(bin2o) -include $(DEPENDS)
Finally, let's get to writing the meat of the program. First, include these two lines of code wherever necessary:
#include "ftImage.h" //The ftimage library
#include "namefthefontinthedatafolder_ttf.h" //Font being used (you have it in the data folder)
Now, wherever appropriate, declare these two objects:
ftImage print(640, 480); //This will store the string of text we print
Sprite Text; //This Sprite will be used to render the ftImage member print
Now, this little snippet of code is all we need to prepare our objects to store and render text:
print.setFont(fthenameofthefontinthedatafolder_ttf, thenameofthefontinthedatafolder_ttf_size);//Set the font we are using
print.setSize(32);//Set the size of the font (should be a multiple of 4)
print.setColor(Color::Color(255,40,40));//Set the color of the font in RGB format
Text.SetPosition(100, 50);//Set the position of the starting point of the text we will print
Text.SetImage(&print);//Append print as the image stored by Text
You do not need to use the above code in the order that I did. You can also feel free to change the values used by it at anytime during the course of your program.
And finally, here's how we render text:
print.printf(" Hellow World!\n");//Set the string of text to be rendered (escape characters can be use to render more than one line)
print.flush();//Tell the computer that the string of text is ready
Text.Draw();//Render the text
print.clear();//Clear the stored string of text
print.reset();//Bring us back to the render starting point (defined by Text.SetPosisition())
You'll want to use all of that above code in every loop that render text. If you render text without calling clear() and reset(), the next time you render text; you will render the same text as last time plus the new text you want to render.
Thanks to ArminTamazarian for whom without FreeTypeGX, this guide would never have been possible. Thanks to my good friend Ave for whom without ftimage, this guide would also never have been possible. Thanks Ave, for also being a good friend and helping me with tons of stuff at the drop of a hat. I'd never be where I am today without you.
Labels:
C++,
tutorial,
wii homebrew development
Sunday, July 19, 2009
How to use Mibbit to Connect to the IRC from your Web Browser
Mibbit is a unique IRC client that allows people to connect to and participate in the IRC from their Web Browser. The purpose of this post is to show you how to connect to any IRC Channel using Mibbit.
First let's go to the Mibbit website by clicking here.
Click on the image link on the left that says, "Start Chatting Now"
Now you'll be presented with a mostly green background with three boxes in the middle. We're going to ignore the lower two boxes (that say "Browse IRC Networks" and "Login to IM [ Twitter ]") and focus only on the top box that says "IRC"
Next to the word "IRC" there is a drop-down menu. Every selection you can choose in this menu is a different server you can connect to. For the purposes of this tutorial, choose the server "EFNET [webirc]"
Now, in the box below that says "Nick:" Enter in a screen name that you would like to use in the IRC.
Penultimately, in the box on the right that says "Channel:" Enter in the IRC channel you would like to connect to. For the purposes of this tutorial, lets use #arikadosblog
Now finally, click the action button "Go" on the right of the channel box and you'll be connected to #arikadosblog on EFNET.
To join more channels on the server, or network, you connected to (EFNET in this tutorial) type: /join #thechannelyouwanttojoin and a new tab in mibbit will open up connecting you to that IRC channel. Other channels you may wish to join are #wiihelp and #tehskeen on EFNET.
See you on the IRC,
Arikado
First let's go to the Mibbit website by clicking here.
Click on the image link on the left that says, "Start Chatting Now"
Now you'll be presented with a mostly green background with three boxes in the middle. We're going to ignore the lower two boxes (that say "Browse IRC Networks" and "Login to IM [ Twitter ]") and focus only on the top box that says "IRC"
Next to the word "IRC" there is a drop-down menu. Every selection you can choose in this menu is a different server you can connect to. For the purposes of this tutorial, choose the server "EFNET [webirc]"
Now, in the box below that says "Nick:" Enter in a screen name that you would like to use in the IRC.
Penultimately, in the box on the right that says "Channel:" Enter in the IRC channel you would like to connect to. For the purposes of this tutorial, lets use #arikadosblog
Now finally, click the action button "Go" on the right of the channel box and you'll be connected to #arikadosblog on EFNET.
To join more channels on the server, or network, you connected to (EFNET in this tutorial) type: /join #thechannelyouwanttojoin and a new tab in mibbit will open up connecting you to that IRC channel. Other channels you may wish to join are #wiihelp and #tehskeen on EFNET.
See you on the IRC,
Arikado
Friday, July 10, 2009
How to play external MP3 Files with libogc's MP3Player
It's hard for me to get into detailing the subject of this post without me providing a little preface detailing my experiences so far with libogc's MP3Player. This way, you'll know where I stand and why it takes such a complex method to play externally loaded .mp3s. Also, be aware that I've spent at least a good 15 hours working with the MP3Player over the course of my Wii Homebrew developments.
Libogc's MP3Player is nice in that it allows the programmer to play MP3 files loaded externally from the SD Card, or loaded internally from the RAM as a buffer. While I've always had surefire success with the latter method, the former has been hit or miss. When I have gotten it to work, I've always been unable to get the .mp3s to play on a loop. Any calls relating to the FILE holding the .mp3's freezes the Wii forcing me to physically get up from my chair and unplug the Wii. To that end, it's quite a conundrum to have such a wonderful MP3Player_PlayBuffer() function and such an unstable MP3Player_PlayFile() function.
However, to this day, I still haven't given up trying to play externally loaded MP3 files with libogc's MP3 Player. And today, I'm pleased to post on my blog that I've finally found a very stable, working, solution. The solution is, to put it plainly, to load an external MP3 file, turn it into a buffer, and then play the buffer with the MP3 Player. The rest of this post will detail the exact the code I used to get this to work.
First, in your makefile, under LIBS:, include the libasnd.a libmad.a libraries:
-lasnd -lmad
Now, wherever necessary, include asnd and the libogc MP3Player:
#include (asndlib.h)
#include (mp3player.h)
And of course, initialize asnd and the libogc MP3Player before you do anything with them:
ASND_Init();
MP3Player_Init();
Let's declare all of the variables we're going to use:
FILE *BGM = 0;//This will store an MP3 on the SD Card
long lSize;//This will store the size of the FILE BGM
char * buffer;//This is our buffer that will take the place of the external MP3
size_t result;//This is the size of the buffer
bool mp3isready = false;//This keeps the music from trying to loop before the buffer is made
And now prototype a simple function that will keep the MP3 looping:
void LoopTheMP3();
Now let's load an MP3 file:
mp3isready = false;//Keeps LoopTheMP3() from working before the buffer is ready
BGM = fopen("sd:/MUSIC/bgm.mp3", "rb");
Let's obtain the size of said file:
fseek (BGM , 0 , SEEK_END);
lSize = ftell (BGM);
rewind (BGM);//Return to the beginning of the MP3 for good measure
Create the Buffer:
buffer = (char*) malloc (sizeof(char)*lSize);//Allocate memory to contain the whole file
result = fread (buffer,1,lSize,BGM);//Copy the file into the buffer
Play the Buffer:
fclose(BGM);//Since we no longer need BGM, get rid of it
MP3Player_PlayBuffer(buffer, lSize, NULL);//Play the buffer
mp3isready = true;//Let LoopTheMP3() know it can start working
If you're going to change songs, be sure to clear the buffer beforehand:
free(buffer);
Lastly, heres the code for our function to keep the MP3 Playing continuously:
void LoopTheMP3(){
if(mp3isready && !MP3Player_IsPlaying())
MP3Player_PlayBuffer(buffer, lSize, NULL);
}
As is the nature of programming, this code will probably need to be adapted and changed a bit to suit the flow of your program. However, I assure you that it does work and is the most stable way I've encountered yet to play externally loaded MP3 files. I have pastied the exact code I am using in Wii Shooting Gallery here to show you an example of that. I have another app (with source of course) made just to demonstrate the functionality here.
Special thanks go out to scanff who, without his support, I would've given up on libogc's MP3Player before ever even trying a buffer (that means there would've been no sound in WiiBreaker without his help :-O). Thanks to him, I've managed to continually expand my knowledge and bring you the solution I found; detailed in this post.
Libogc's MP3Player is nice in that it allows the programmer to play MP3 files loaded externally from the SD Card, or loaded internally from the RAM as a buffer. While I've always had surefire success with the latter method, the former has been hit or miss. When I have gotten it to work, I've always been unable to get the .mp3s to play on a loop. Any calls relating to the FILE holding the .mp3's freezes the Wii forcing me to physically get up from my chair and unplug the Wii. To that end, it's quite a conundrum to have such a wonderful MP3Player_PlayBuffer() function and such an unstable MP3Player_PlayFile() function.
However, to this day, I still haven't given up trying to play externally loaded MP3 files with libogc's MP3 Player. And today, I'm pleased to post on my blog that I've finally found a very stable, working, solution. The solution is, to put it plainly, to load an external MP3 file, turn it into a buffer, and then play the buffer with the MP3 Player. The rest of this post will detail the exact the code I used to get this to work.
First, in your makefile, under LIBS:, include the libasnd.a libmad.a libraries:
-lasnd -lmad
Now, wherever necessary, include asnd and the libogc MP3Player:
#include (asndlib.h)
#include
And of course, initialize asnd and the libogc MP3Player before you do anything with them:
ASND_Init();
MP3Player_Init();
Let's declare all of the variables we're going to use:
FILE *BGM = 0;//This will store an MP3 on the SD Card
long lSize;//This will store the size of the FILE BGM
char * buffer;//This is our buffer that will take the place of the external MP3
size_t result;//This is the size of the buffer
bool mp3isready = false;//This keeps the music from trying to loop before the buffer is made
And now prototype a simple function that will keep the MP3 looping:
void LoopTheMP3();
Now let's load an MP3 file:
mp3isready = false;//Keeps LoopTheMP3() from working before the buffer is ready
BGM = fopen("sd:/MUSIC/bgm.mp3", "rb");
Let's obtain the size of said file:
fseek (BGM , 0 , SEEK_END);
lSize = ftell (BGM);
rewind (BGM);//Return to the beginning of the MP3 for good measure
Create the Buffer:
buffer = (char*) malloc (sizeof(char)*lSize);//Allocate memory to contain the whole file
result = fread (buffer,1,lSize,BGM);//Copy the file into the buffer
Play the Buffer:
fclose(BGM);//Since we no longer need BGM, get rid of it
MP3Player_PlayBuffer(buffer, lSize, NULL);//Play the buffer
mp3isready = true;//Let LoopTheMP3() know it can start working
If you're going to change songs, be sure to clear the buffer beforehand:
free(buffer);
Lastly, heres the code for our function to keep the MP3 Playing continuously:
void LoopTheMP3(){
if(mp3isready && !MP3Player_IsPlaying())
MP3Player_PlayBuffer(buffer, lSize, NULL);
}
As is the nature of programming, this code will probably need to be adapted and changed a bit to suit the flow of your program. However, I assure you that it does work and is the most stable way I've encountered yet to play externally loaded MP3 files. I have pastied the exact code I am using in Wii Shooting Gallery here to show you an example of that. I have another app (with source of course) made just to demonstrate the functionality here.
Special thanks go out to scanff who, without his support, I would've given up on libogc's MP3Player before ever even trying a buffer (that means there would've been no sound in WiiBreaker without his help :-O). Thanks to him, I've managed to continually expand my knowledge and bring you the solution I found; detailed in this post.
Labels:
arikado,
tutorial,
wii homebrew development
Friday, July 3, 2009
How to fix your Homebrew Channels Black Screen
Lately, users installing or updating the Homebrew Channel are facing a common issue. I'm dubbing it, "The Black Screen Issue"
If you receive only a black screen when you start your homebrew channel, then you are inflicted with "The Black Screen Issue"
Fixing this problem is easy, the solution only takes 3 simple steps.:
Still have problems?
Log onto #wiihelp at EFNET and be helped immediately. You can log on with your web browser via Mibbit by clicking here. Also, you can e-mail me, Arikado, for help.
If you receive only a black screen when you start your homebrew channel, then you are inflicted with "The Black Screen Issue"
Fixing this problem is easy, the solution only takes 3 simple steps.:
- Run the application WiiSCU with Bannerbomb and have it install IOS 60
- Uninstall the homebrew channel via Bannerbomb and the HackMii Installer
- Reinstall the homebrew channel (via Bannerbomb and the HackMii Installer)
Still have problems?
Log onto #wiihelp at EFNET and be helped immediately. You can log on with your web browser via Mibbit by clicking here. Also, you can e-mail me, Arikado, for help.
Labels:
tutorial,
wii homebrew
Thursday, July 2, 2009
if ... then with C/C++
Absolutely the most central part of the core of every program is the if ... then statements of every program. The purpose of an if ... then statement is to check to see if something is true, and then perform an action if it is true.
Let me give you a few examples:
if(value_one check value_two){
code to execute if the if statement is true
}
Here is a long, although perfectly practical example of a use of all of the basic if statements in a simple C/C++ program:
#include (iostream)
int main(){
int janes_age = 0;
int bills_age = 0;
std::cout << "How old is Jane?";
std::cin >> janes_age;
std::cout << "How old is Bill?";
std::cin >> bills_age;
//Now lets see how their ages compare
if(janes_age == bills_age){
std::cout << "Jane is the same age as Bill";
}
if(janes_age != bills_age){
std::cput << "Jane is not the same age as Bill";
}
if(janes_age > bills_age){
std::cout << "Jane is older than Bill";
}
if(janes_age <= bills_age){
std::cout << "Bill is older than or the same age as Jane.";
}
if(bills_age <= janes_age){
std::cout << "Bill is younger than or the same age as Jane.";
}
if(!janes_age){ std::cout << "Jane is not even more than 0 years old yet!";
}
if(bills_age){
std::cout << "Bill is more than 0 years old.";
}
int pause;
cin >> pause;
return 0;
}
The program listed above creates two variables representing the age of two people; Bill and Jane. The program than asks the user to assign a values to be held by each variable. After wards, the program uses all of the seven basic if statements to compare the variables and output text if each if statement is true. But would happen if your programming duties asked you, the programmer, to compare the truth behind two if ... then statements and then execute code if they were both true? Here's a few examples to show you what I mean:
if(janes_age < bills_age && janes_age < 5){
std::cout << "Jane is younger than Bill because she is only a toddler.";
}
In this example, the if statement is only tue if Janes age is less than Bills age and if Jane is less than 5. If either one or both of these two statements is false, then the if ... then statement is not true and the computer will not output, "Jane is younger than Bill because she is only a toddler." The following would also work the same way as the above example:
if((janes_age < bills_age) && (janes_age < 5)){
std::cout << "Jane is younger than Bill because she is only a toddler.";
}
The extra set of parenthesis in this second example does nothing to change the statement but many programmers, myself included, feel that is makes the if statement look more clear. This is especially true when you're writing complex if ... then statements such as collison routines ;-) The other, last, type of clause used in if statements is the or clause. The or clause only returns true if at least one of it's depending statements are true. Heres a few examples of using an or clause:
if((janes_age > bills_age) || (bills_age < janes_age)){
std::cout << "Jane is older than Bill";
}
In this example the computer will output, "Jane is older than Bill" if either janes_age is greater than bills_age or bills_age less than janes_age.
if ... then statements are used literally everwhere in programming. Every laguage harnesses them, and every program has too many of them to count. While the examples provided here were simple, the core idea I hope I got across to you, the reader, is that without if ... then statements computer programs as we know them would not exist. (And I also hoped you learned how to properly use them in your C/C++ programs as well ;-) )
Let me give you a few examples:
- If Mario is hit by a barrel, then get rid of one of the players lives
- If a user is banned, then do not let them post comments
- If dogs hate cats, then dogs fight with cats
- If a new video game is a AAA title, then it will sell a lot of copies
- If a value is equal to another value ( == )
- If a value is not equal to another value ( != )
- If a value is greater than another value ( > )
- If a value is less then another value ( < )
- If a value is greater than or equal to another value ( >= )
- If a value is less than or equal to another value ( <= )
- If a value is greater than 0 ()
- If a value is less than or equal to zero (!)
if(value_one check value_two){
code to execute if the if statement is true
}
Here is a long, although perfectly practical example of a use of all of the basic if statements in a simple C/C++ program:
#include (iostream)
int main(){
int janes_age = 0;
int bills_age = 0;
std::cout << "How old is Jane?";
std::cin >> janes_age;
std::cout << "How old is Bill?";
std::cin >> bills_age;
//Now lets see how their ages compare
if(janes_age == bills_age){
std::cout << "Jane is the same age as Bill";
}
if(janes_age != bills_age){
std::cput << "Jane is not the same age as Bill";
}
if(janes_age > bills_age){
std::cout << "Jane is older than Bill";
}
if(janes_age <= bills_age){
std::cout << "Bill is older than or the same age as Jane.";
}
if(bills_age <= janes_age){
std::cout << "Bill is younger than or the same age as Jane.";
}
if(!janes_age){ std::cout << "Jane is not even more than 0 years old yet!";
}
if(bills_age){
std::cout << "Bill is more than 0 years old.";
}
int pause;
cin >> pause;
return 0;
}
The program listed above creates two variables representing the age of two people; Bill and Jane. The program than asks the user to assign a values to be held by each variable. After wards, the program uses all of the seven basic if statements to compare the variables and output text if each if statement is true. But would happen if your programming duties asked you, the programmer, to compare the truth behind two if ... then statements and then execute code if they were both true? Here's a few examples to show you what I mean:
- If Mario is hit by a barrel and the player's health is equal to 1, then the game is over
- If dogs hate cats and cats hate dogs, then dogs and cats fight
- If a new game is a AAA title and it was developed by Davide Jaffe, then it will sell lots of copies
if(janes_age < bills_age && janes_age < 5){
std::cout << "Jane is younger than Bill because she is only a toddler.";
}
In this example, the if statement is only tue if Janes age is less than Bills age and if Jane is less than 5. If either one or both of these two statements is false, then the if ... then statement is not true and the computer will not output, "Jane is younger than Bill because she is only a toddler." The following would also work the same way as the above example:
if((janes_age < bills_age) && (janes_age < 5)){
std::cout << "Jane is younger than Bill because she is only a toddler.";
}
The extra set of parenthesis in this second example does nothing to change the statement but many programmers, myself included, feel that is makes the if statement look more clear. This is especially true when you're writing complex if ... then statements such as collison routines ;-) The other, last, type of clause used in if statements is the or clause. The or clause only returns true if at least one of it's depending statements are true. Heres a few examples of using an or clause:
- If Mario is hit by a barrel or a fireball, then Mario is dead.
- If dogs hate cats or cats hate dogs, then dogs and cats fight
- If a user is banned permanently or temporarily, then he can not post comments
if((janes_age > bills_age) || (bills_age < janes_age)){
std::cout << "Jane is older than Bill";
}
In this example the computer will output, "Jane is older than Bill" if either janes_age is greater than bills_age or bills_age less than janes_age.
if ... then statements are used literally everwhere in programming. Every laguage harnesses them, and every program has too many of them to count. While the examples provided here were simple, the core idea I hope I got across to you, the reader, is that without if ... then statements computer programs as we know them would not exist. (And I also hoped you learned how to properly use them in your C/C++ programs as well ;-) )
Tuesday, June 16, 2009
How to fix Nintendos Save and Channel Copy Protection on 4.0
Many of you (myself included) have updated your Wiis to System Menu Version 4.0 However, upon updating, you had a lot of problems with your SD Card transferring and SD Card Menu functionality.
You realized that you couldn't launch some of your channels from the SD Card Menu or even move them to the Wii Menu. You also realized that some of your save games could no longer be moved to your Wii's System Memory from your SD Card (the twilight hack save being one of them).
All of this happened because of new copy protection features Nintendo put into System Menu 4.0 that no longer allow users to transfer or use fakesigned content on their SD Cards, thus rendering it useless.
Thankfully, there is an easy solution to fix all of this. You may recall that an IOS is one of many low level input/output systems that run on the Wii's coprocessor. The IOS responsible for Nintendo's copy protection features in 4.0 is IOS 60. To disable the copy protection features, one must simple insert the trucha (fakesigning) bug into their IOS 60.
This is a lot simpler to do than it sounds. There are actually a couple of ways to do this, all of which are listed below:
If this guide helped you, please help me by giving the link of it to others who need it.
You realized that you couldn't launch some of your channels from the SD Card Menu or even move them to the Wii Menu. You also realized that some of your save games could no longer be moved to your Wii's System Memory from your SD Card (the twilight hack save being one of them).
All of this happened because of new copy protection features Nintendo put into System Menu 4.0 that no longer allow users to transfer or use fakesigned content on their SD Cards, thus rendering it useless.
Thankfully, there is an easy solution to fix all of this. You may recall that an IOS is one of many low level input/output systems that run on the Wii's coprocessor. The IOS responsible for Nintendo's copy protection features in 4.0 is IOS 60. To disable the copy protection features, one must simple insert the trucha (fakesigning) bug into their IOS 60.
This is a lot simpler to do than it sounds. There are actually a couple of ways to do this, all of which are listed below:
- Have the application "WAD Manager" install my patched IOS 60 WAD.
- Have the application "WiiSCU" install a patched IOS 60 (trucha+)
If this guide helped you, please help me by giving the link of it to others who need it.
Labels:
tutorial,
wii homebrew
Friday, June 5, 2009
The Ultimate (free) Guide to Installing Homebrew on your Nintendo Wii
Who am I?: I am Arikado. I am developer of two Wii Homebrew applications and a Wii Homebrew developers library. I am also the moderator of the WiiBrew forums.
Preface: Homebrew is a term used to refer to the practice of running code that is "home-made" or unauthorized for the sytem it is running on. Running homebrew on any type of a console opens up a door of opportunity to developers, and most of all, users (AKA you the reader). This guide will tell you both why you should put homebrew on your Wii and how to do it.
Why install homebrew on your Wii?
The easiest way for me to explain why you should install homebrew on your Wii is to have you look at a list of all the things you can do with your Wii after you have installed homebrew on it. Click this link here and take a visit to WiiBrew (the mother of Wii Homebrew) and check out all of the cool applications you can run with Wii Homebrew.
Some of the coolest features of having Wii Homebrew installed (in case you didnt see them in the link above) are:
How to install Homebrew on your Nintendo Wii
To install Homebrew on your Wii, you need a way to run unsigned code on your Wii. This is also known as an exploit. If you are on system menu 3.4 or lower, you can use the Twilight Hack, Bannerbomb, or Indiana Pwns exploits. If you are on system menu 4.0 or higher, you must use the Banneromb exploit. People on system menu 4.2 must be sure to use v2 of Bannerbomb. Indiana Pwns will work on Wii system menu. The only tool you need to run these exploits and use them to install homebrew is an SD Card.
Before we set up to use an exploit, let's set up our SD Card first. It's important that your SD Card is no smaller than 256mb or else homebrew will not work with your SD Card. First, download the Hackmii Installer from here. Use a tool like Winrar, Winzip, or 7zip to extract the Hackmii Installer. Find the file named installer.elf and place it in the root (the main directory, AKA inside of no folders) of your SD Card. Rename the file to boot.elf
Below, are the ways to set up each of the two exploits on your SD Card. Again, you only need to use one, so pick whatever one you prefer. Bannerbomb is the easiest exploit to use, because everyone can use it regardless of their System Menu version. It is also a lot easier to set up and doesn't require you to own a copy of Twilight Princess or LEGO Indiana Jones.
Be sure to turn off WiiConnect24 before you attempt to run either exploit.
Bannerbomb
Bannerbomb can be found and downloaded here. Below are the official instructions for setting up Bannerbomb on your SD Card. I couldn't write them better if I tried.
Indiana Pwns can be found and downloaded here. Here are the step-by-step instructions to use it, taken straight from the wiki page:"
The Twilight Hack can be found and downloaded here. Here are the step-by-step instructions to use it, taken right from the wiki page:"
No matter which exploit you choose to use, after running the exploit, the HackMii Installer should start and you will be able to install the Homebrew Channel, DVDX, and/or Bootmii. Be sure to install the Homebrew Channel - it's the most important obviously.
Running apps with the homebrew channel
To run homebrew with the Homebrew Channel, you first need to create a folder a called "apps" (without the quotes of course) in the root of your SD Card. Every app you download, will need to be extracted, and then placed in this folder to be able to be run with the Homebrew Channel. In other words, the path of each app on your SD Card should look like this: root:apps/afolder/boot.dol or root:apps/afolder/boot.elf
Troubleshooting
Read the FAQ I wrote to solve your common troubleshooting issues and problems
Good luck, and have fun with Wii Homebrew :D
Final Notes: If you were able to succesfully install homebrew on your Wii with this guide, please send the link of this guide to others. If you need one-on-one assistance, feel free to e-mail me, Arikado, at castlevania7689@yahoo.com I will help you o the best of my ability with anything to do with this guide, or more advanced Wii Homebrew and wii hacking problems. Feel free to follow me on Twitter here: http://twitter.com/OArikadoO
Preface: Homebrew is a term used to refer to the practice of running code that is "home-made" or unauthorized for the sytem it is running on. Running homebrew on any type of a console opens up a door of opportunity to developers, and most of all, users (AKA you the reader). This guide will tell you both why you should put homebrew on your Wii and how to do it.
Why install homebrew on your Wii?
The easiest way for me to explain why you should install homebrew on your Wii is to have you look at a list of all the things you can do with your Wii after you have installed homebrew on it. Click this link here and take a visit to WiiBrew (the mother of Wii Homebrew) and check out all of the cool applications you can run with Wii Homebrew.
Some of the coolest features of having Wii Homebrew installed (in case you didnt see them in the link above) are:
- The ability to watch dvd's on your Wii
- The ability to run emulators so you can play games on the NES, SNES, N64, GBA, GB/GBC, the PS1 and even more systems on your Wii.
- The ability to play ports of famous id Software games like Quake, DOOM, and Wolfenstein.
- The ability to play tons of original homebrew games (I am the author of two by the way)
- The ability to change your system menu's region (from Japanese to European or USA or vice versa for example)
- The ability to play Wii disc games from another region
- The ability to back up your Wii's NAND (also known as the Wii's internal memory) so you can restore it and fix your Wii if something fatal should ever happen to it (like you turn the power off in the middle of an update for instance)
How to install Homebrew on your Nintendo Wii
To install Homebrew on your Wii, you need a way to run unsigned code on your Wii. This is also known as an exploit. If you are on system menu 3.4 or lower, you can use the Twilight Hack, Bannerbomb, or Indiana Pwns exploits. If you are on system menu 4.0 or higher, you must use the Banneromb exploit. People on system menu 4.2 must be sure to use v2 of Bannerbomb. Indiana Pwns will work on Wii system menu. The only tool you need to run these exploits and use them to install homebrew is an SD Card.
Before we set up to use an exploit, let's set up our SD Card first. It's important that your SD Card is no smaller than 256mb or else homebrew will not work with your SD Card. First, download the Hackmii Installer from here. Use a tool like Winrar, Winzip, or 7zip to extract the Hackmii Installer. Find the file named installer.elf and place it in the root (the main directory, AKA inside of no folders) of your SD Card. Rename the file to boot.elf
Below, are the ways to set up each of the two exploits on your SD Card. Again, you only need to use one, so pick whatever one you prefer. Bannerbomb is the easiest exploit to use, because everyone can use it regardless of their System Menu version. It is also a lot easier to set up and doesn't require you to own a copy of Twilight Princess or LEGO Indiana Jones.
Be sure to turn off WiiConnect24 before you attempt to run either exploit.
Bannerbomb
Bannerbomb can be found and downloaded here. Below are the official instructions for setting up Bannerbomb on your SD Card. I couldn't write them better if I tried.
- "If your SD card has a private directory, rename it temporarily, e.g. to "privateold". Having other saved channels on the same card will screw it up. (Also, if you don't have any channels on the SD card already, it's possible to skip this step so you can keep saves on your SD card)
- Copy the Bannerbomb "private" folder to the root of your SD card.
- Take your Wii executable, name it "boot.dol" or "boot.elf" if it isn't already, and save it in the root directory of your SD card.
- Put your SD card in your Wii and turn it on.
- Go into Wii Options --> Data Management --> Channels --> SD Card.
- A message should appear asking to "load boot.dol/.elf". If it freezes or does not appear, download the next .zip file from the Bannerbomb website and start over.
- The homebrew on your SD card will load. Enjoy!"
Indiana Pwns can be found and downloaded here. Here are the step-by-step instructions to use it, taken straight from the wiki page:"
- Ensure your SD card is formatted as FAT. By default SD cards are formatted as FAT, so if you're not sure, you may skip this step.
- (Optional) If you have an existing Indiana save that you want to backup, do so before proceeding:
- Put your SD card in your Wii.
- Go into Wii Options ⇒ Data Management ⇒ Save Data ⇒ Wii
- Find your Indiana save, click on it, click "Copy", and click Yes.
- Put your SD card in your computer, and copy the "private" folder from the card to a safe place.
- Copy the "private" directory from the Indiana Pwns download to the root of your SD card.
- Take your homebrew Wii executable (ELF file) and save it in the root directory of your SD card as "boot.elf".
- Put your SD card in your Wii and turn it on.
- Go into Wii Options ⇒ Data Management ⇒ Save Data ⇒ Wii.
- Find your Indiana save, click on it, click "Erase", and click Yes.
- Open the SD card and select the "Indiana Pwns" save that corresponds to your game region. Note: Some people are having problems with the Wii not "seeing" the save file on the SD card. If you are experiencing this, try setting the archive bit for the data.bin file - in Windows this can be either be done from the file's properties dialog (right click on it in Windows Explorer and check the box) or from the command line using "attrib +a
". More info at #wiihelp on Efnet. - Click copy and then yes. Now exit out of the menu.
- Insert LEGO Indiana Jones disc and run the game.
- From the Indiana game, load the saved game you just copied to the Wii.
- When the game loads, you will be in Barnett College. Walk to the Art Room (through the Courtyard), approach the left character on the podium. When it zooms on him, choose the switch to option (two silhouettes, staggered, with an arrow pointing between them).
- Here, the buffer overflow takes over and the Homebrew install will begin."
The Twilight Hack can be found and downloaded here. Here are the step-by-step instructions to use it, taken right from the wiki page:"
- Ensure your SD card is formatted as FAT. By default SD cards are formatted as FAT, so if you're not sure you can skip this step.
- (Optional) If you have an existing Zelda save that you want to backup, do so before proceeding:
- Put your SD card in your Wii and turn it on.
- Go into Wii Options --> Data Management --> Save Data --> Wii
- Find your Zelda save, click on it, click "Copy", and click Yes
- Put your SD card in your computer, and copy the "private" folder from the card to a safe place.
- Copy the "private" directory from the Twilight Hack download to the root of your SD card.
- Take your homebrew Wii executable (elf or dol file) and save it in the root directory of your SD card as "boot.elf" or "boot.dol" as appropriate.
- Put your SD card in your Wii and turn it on.
- Go into Wii Options --> Data Management --> Save Data --> Wii.
- Find your Zelda save, click on it, click "Erase", and click Yes.
- Open the SD card and select the "Twilight Hack" save that corresponds to your game region. Note: Some people are having problems with the Wii not "seeing" the save file on the SD card. If you are experiencing this, try setting the archive bit for the data.bin file - in Windows this can be either be done from the file's properties dialog (right click on it in Windows Explorer and check the box) or from the command line using "attrib +a
". More info at #wiihelp on Efnet. - Click copy and then yes. Now exit out of the menu.
- If you are using System Menu 3.4, you must immediately put the Twilight Hack to use. Turning off or running some other channel or game will have the System Menu delete the savegame again, and you'll have to start over.
- Insert The Legend of Zelda: Twilight Princess game disc and run the game.
- If you have the USA version of the game, load the "TwilightHack0" or "TwilightHack2" version of the game as appropriate (see above).
- Otherwise, load the only "Twilight Hack" save game.
- Once in the game, either walk backwards or talk to the man standing in front of you.
- Follow the instructions listed on the screen.
- Enjoy."
No matter which exploit you choose to use, after running the exploit, the HackMii Installer should start and you will be able to install the Homebrew Channel, DVDX, and/or Bootmii. Be sure to install the Homebrew Channel - it's the most important obviously.
Running apps with the homebrew channel
To run homebrew with the Homebrew Channel, you first need to create a folder a called "apps" (without the quotes of course) in the root of your SD Card. Every app you download, will need to be extracted, and then placed in this folder to be able to be run with the Homebrew Channel. In other words, the path of each app on your SD Card should look like this: root:apps/afolder/boot.dol or root:apps/afolder/boot.elf
Troubleshooting
Read the FAQ I wrote to solve your common troubleshooting issues and problems
Good luck, and have fun with Wii Homebrew :D
Final Notes: If you were able to succesfully install homebrew on your Wii with this guide, please send the link of this guide to others. If you need one-on-one assistance, feel free to e-mail me, Arikado, at castlevania7689@yahoo.com I will help you o the best of my ability with anything to do with this guide, or more advanced Wii Homebrew and wii hacking problems. Feel free to follow me on Twitter here: http://twitter.com/OArikadoO
Labels:
bannerbomb,
homebrew channel,
tutorial,
wii homebrew,
wiibrew
Subscribe to:
Posts (Atom)