about summary refs log tree commit diff stats
path: root/source/main.c
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-09-10 17:16:52 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-09-10 17:16:52 -0400
commit1d82e3affd42c2336702af4a644baa8eec249ead (patch)
treeaeea397863a7d2014bd960a9bd3ba090f841bcce /source/main.c
parent0882d1020d75bbddc8e8fbe30aed435e8814988a (diff)
downloadgen3uploader-1d82e3affd42c2336702af4a644baa8eec249ead.tar.gz
gen3uploader-1d82e3affd42c2336702af4a644baa8eec249ead.tar.bz2
gen3uploader-1d82e3affd42c2336702af4a644baa8eec249ead.zip
Increased stability and added support for non-English names
The GameCube side of the program now can convert from the propietary
character set to UTF-8. This is useful for representing names of Pokémon
and players in a neutral way. The propietary character set is mostly
compatible between the six languages supported by the games (as in, the
hiragana and katakana characters unique to Japanese occupy spaces not
used by the other languages for names, as do the letters with umlauts
unique to German). However, six codepoints differ between the Japanese
and non-Japanese character sets, and an additional two differ even
amongst the non-Japanese sets. Because of this, the function that
converts to UTF-8 takes a language as a parameter, and uses the correct
characters for that language.

From there, the behavior of this function differs slightly to that of
the games. In the non-Japanese games, the Japanese encoding is used if
the Pokémon in question originated in a Japanese game, and the
non-Japanese encoding (disregarding the regional differences in the two
codepoints mentioned earlier) otherwise. In the Japanese games, the
Japanese encoding is used regardless of the Pokémon's origin. The
decoding function I wrote always uses the character set corresponding to
the language of the Pokémon's origin, because that most accurately
represents the name given to it, and will not change just because the
Pokémon was traded to a different game. The character set used for the
name of the player is the one corresponding to the language of the
cartridge.

Additionally, a number of changes were made to the communication
protocol between the GameCube and the GBA that appear to have
dramatically increased stability. The most significant of these is
likely that the transfer delay was increased tenfold. This causes the
multiboot image to take slightly longer to download to the GBA, but the
difference is not large enough to outweigh the benefits of the increased
stability.
Diffstat (limited to 'source/main.c')
-rw-r--r--source/main.c51
1 files changed, 14 insertions, 37 deletions
diff --git a/source/main.c b/source/main.c index ceb24d5..1355533 100644 --- a/source/main.c +++ b/source/main.c
@@ -10,6 +10,7 @@
10#include <stdio.h> 10#include <stdio.h>
11#include <stdlib.h> 11#include <stdlib.h>
12#include <unistd.h> 12#include <unistd.h>
13#include <string.h>
13#include "link.h" 14#include "link.h"
14#include "encoding.h" 15#include "encoding.h"
15#include "multiboot.h" 16#include "multiboot.h"
@@ -117,6 +118,7 @@ void* extractor(void* userdata)
117 118
118 printf("\n"); 119 printf("\n");
119 VIDEO_WaitVSync(); 120 VIDEO_WaitVSync();
121 sleep(1);
120 122
121 u32 isValid = getMsg(); 123 u32 isValid = getMsg();
122 if (isValid == -1) 124 if (isValid == -1)
@@ -144,19 +146,13 @@ void* extractor(void* userdata)
144 // Get trainer ID 146 // Get trainer ID
145 u32 trainerId = getMsg(); 147 u32 trainerId = getMsg();
146 148
147 printf("Trainer: "); 149 // Get game language.
150 enum PokemonLanguage gameLanguage = getMsg();
148 151
149 for (int i = 0; i < 8; i++) 152 char d_trainerName[25];
150 { 153 decodePokemonCharset(trainerName, 8, d_trainerName, gameLanguage);
151 if (trainerName[i] == 0xFF)
152 {
153 break;
154 } else {
155 printf("%c", debugGen3Decode(trainerName[i]));
156 }
157 }
158 154
159 printf(" (%ld)\n", trainerId); 155 printf("Trainer: %s (%ld)\n", d_trainerName, trainerId);
160 156
161 // Wait for confirmation. 157 // Wait for confirmation.
162 printf("Press A to import the data from this game.\n"); 158 printf("Press A to import the data from this game.\n");
@@ -219,34 +215,15 @@ void* extractor(void* userdata)
219 215
220 struct PokemonIntermediate* pki = (struct PokemonIntermediate*)(&rawdata); 216 struct PokemonIntermediate* pki = (struct PokemonIntermediate*)(&rawdata);
221 217
222 printf("Species: %d\n", __builtin_bswap16(pki->species)); 218 char d_pokename[31];
223 219 decodePokemonCharset(pki->nickname, 10, d_pokename, pki->language);
224 u8* pokename = pki->nickname;
225 printf("Nickname: ");
226
227 for (int i = 0; i < 10; i++)
228 {
229 if (pokename[i] == 0xFF)
230 {
231 break;
232 } else {
233 printf("%c", debugGen3Decode(pokename[i]));
234 }
235 }
236 220
237 printf("\nOT: "); 221 char d_otName[22];
222 decodePokemonCharset(pki->otName, 7, d_otName, pki->language);
238 223
239 for (int i=0; i<7; i++) 224 printf("Species: %d\n", __builtin_bswap16(pki->species));
240 { 225 printf("Nickname: %s\n", d_pokename);
241 if (pki->otName[i] == 0xFF) 226 printf("OT: %s\n", d_otName);
242 {
243 break;
244 } else {
245 printf("%c", debugGen3Decode(pki->otName[i]));
246 }
247 }
248
249 printf("\n");
250 printf("Level: %d\n", pki->level); 227 printf("Level: %d\n", pki->level);
251 printf("HP: %ld\n", __builtin_bswap32(pki->hp)); 228 printf("HP: %ld\n", __builtin_bswap32(pki->hp));
252 printf("Attack: %ld\n", __builtin_bswap32(pki->attack)); 229 printf("Attack: %ld\n", __builtin_bswap32(pki->attack));