Skip to content

Commit

Permalink
kor&jpn support
Browse files Browse the repository at this point in the history
  • Loading branch information
BernardoGiordano committed Feb 2, 2017
1 parent 7671d3d commit ce692e6
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 70 deletions.
29 changes: 7 additions & 22 deletions source/editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,29 +766,19 @@ bool isInfected (u8* pkmn) {
return pkrs > 0;
}

char *getOT(u8* pkmn, char* dst) {
u32 *getOT(u8* pkmn, u32* dst) {
u16 src[NICKNAMELENGTH];
memcpy(src, &pkmn[0xB0], NICKNAMELENGTH);

int cnt = 0;
while (src[cnt] && cnt < 24) {
dst[cnt] = src[cnt];
cnt += 1;
}
dst[cnt] = 0;
utf16_to_utf32(dst, src, NICKNAMELENGTH);
return dst;
}

char *getSaveOT(u8* mainbuf, int game, char* dst) {
u32 *getSaveOT(u8* mainbuf, int game, u32* dst) {
u16 src[NICKNAMELENGTH];
memcpy(src, &mainbuf[(game < 4) ? 0x14048 : 0X1238], NICKNAMELENGTH);

int cnt = 0;
while (src[cnt] && cnt < 24) {
dst[cnt] = src[cnt];
cnt += 1;
}
dst[cnt] = 0;
utf16_to_utf32(dst, src, NICKNAMELENGTH);
return dst;
}

Expand All @@ -800,16 +790,11 @@ u32 *getNickname(u8* pkmn, u32* dst) {
return dst;
}

char *getHTName(u8* pkmn, char* dst) {
u32 *getHTName(u8* pkmn, u32* dst) {
u16 src[NICKNAMELENGTH];
memcpy(src, &pkmn[0x78], NICKNAMELENGTH);

int cnt = 0;
while (src[cnt] && cnt < NICKNAMELENGTH) {
dst[cnt] = src[cnt];
cnt += 1;
}
dst[cnt] = 0;

utf16_to_utf32(dst, src, NICKNAMELENGTH);
return dst;
}

Expand Down
6 changes: 3 additions & 3 deletions source/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ u16 getStat(u8* pkmn, const int stat);
bool getPokerus(u8* pkmn);
u8 getAbility(u8* pkmn);
u8 getAbilityNum(u8* pkmn);
char *getOT(u8* pkmn, char* dst);
char *getHTName(u8* pkmn, char* dst);
u32 *getOT(u8* pkmn, u32* dst);
u32 *getHTName(u8* pkmn, u32* dst);
u32 *getNickname(u8* pkmn, u32* dst);
u16 getEggMove(u8 *pkmn, const int nmove);
u8 getBall(u8* pkmn);
u16 getPSV(u8* pkmn);
char *getSaveOT(u8* mainbuf, int game, char* dst);
u32 *getSaveOT(u8* mainbuf, int game, u32* dst);
u8 getSaveGender(u8* mainbuf, int game);
u16 getSaveTID(u8* mainbuf, int game);
u16 getSaveSID(u8* mainbuf, int game);
Expand Down
49 changes: 26 additions & 23 deletions source/graphic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1056,16 +1056,15 @@ void infoViewer(u8* pkmn, int game) {
sftd_draw_text(fontBold12, 160, 6, WHITE, 12, level);
free(level);

u32 *nick = (u32*)malloc(NICKNAMELENGTH * 2);
memset(nick, 0, NICKNAMELENGTH * 2);
u32 nick[NICKNAMELENGTH*2];
memset(nick, 0, NICKNAMELENGTH*2);
getNickname(pkmn, nick);
sftd_draw_wtext((isKor) ? unicodeKOR12 : unicodeJPN12, 215 - (sftd_get_wtext_width((isKor) ? unicodeKOR12 : unicodeJPN12, 12, (wchar_t*)nick)), 29, WHITE, 12, (wchar_t*)nick);
free(nick);

char *ot_name = (char*)malloc(NICKNAMELENGTH);
u32 ot_name[NICKNAMELENGTH*2];
memset(ot_name, 0, NICKNAMELENGTH*2);
getOT(pkmn, ot_name);
sftd_draw_text(fontBold12, 215 - (sftd_get_text_width(fontBold12, 12, ot_name)), 49, WHITE, 12, ot_name);
free(ot_name);
sftd_draw_wtext((isKor) ? unicodeKOR12 : unicodeJPN12, 215 - (sftd_get_wtext_width((isKor) ? unicodeKOR12 : unicodeJPN12, 12, (wchar_t*)ot_name)), 49, WHITE, 12, (wchar_t*)ot_name);

sftd_draw_text(fontBold12, 215 - sftd_get_text_width(fontBold12, 12, (isInfected(pkmn) ? "Yes" : "No")), 69, WHITE, 12, isInfected(pkmn) ? "Yes" : "No");
sftd_draw_text(fontBold12, 215 - sftd_get_text_width(fontBold12, 12, natures[getNature(pkmn)]), 94, WHITE, 12, natures[getNature(pkmn)]);
Expand Down Expand Up @@ -1240,6 +1239,7 @@ void printPKEditor(u8* pkmn, int game, bool speedy, int additional1, int additio

char* values[6] = {"HP:", "Attack:", "Defense:", "Sp. Attack:", "Sp. Defense:", "Speed:"};
u16 n = getPokedexNumber(pkmn);
bool isKor = (pkmn[0xE3] == 0x08) ? true : false;

sf2d_start_frame(GFX_TOP, GFX_LEFT);
if (mode == ED_BASE || mode == ED_STATS) {
Expand Down Expand Up @@ -1426,15 +1426,15 @@ void printPKEditor(u8* pkmn, int game, bool speedy, int additional1, int additio
sftd_draw_text(fontBold12, 180 - max - 3 + (max - sftd_get_text_width(fontBold12, 12, friendship)) / 2, 189, WHITE, 12, friendship);
free(friendship);

/*wchar_t *nick = (wchar_t*)malloc(NICKNAMELENGTH);
u32 nick[NICKNAMELENGTH*2];
memset(nick, 0, NICKNAMELENGTH*2);
getNickname(pkmn, nick);
sftd_draw_wtext(unicode12, 178 - (sftd_get_wtext_width(unicode12, 12, nick)), 169, WHITE, 12, nick);
free(nick);*/

char *ot_name = (char*)malloc(0x17 * sizeof(char));
sftd_draw_wtext((isKor) ? unicodeKOR12 : unicodeJPN12, 178 - (sftd_get_wtext_width((isKor) ? unicodeKOR12 : unicodeJPN12, 12, (wchar_t*)nick)), 169, WHITE, 12, (wchar_t*)nick);

u32 ot_name[NICKNAMELENGTH*2];
memset(ot_name, 0, NICKNAMELENGTH*2);
getOT(pkmn, ot_name);
sftd_draw_text(fontBold12, 178 - (sftd_get_text_width(fontBold12, 12, ot_name)), 149, WHITE, 12, ot_name);
free(ot_name);
sftd_draw_wtext((isKor) ? unicodeKOR12 : unicodeJPN12, 178 - (sftd_get_wtext_width((isKor) ? unicodeKOR12 : unicodeJPN12, 12, (wchar_t*)ot_name)), 149, WHITE, 12, (wchar_t*)ot_name);
}
if (mode == ED_STATS || mode == ED_HIDDENPOWER) {
sf2d_draw_texture(editorStatsBG, 0, 1);
Expand Down Expand Up @@ -1541,6 +1541,7 @@ void printPKBank(u8* bankbuf, u8* mainbuf, u8* pkmnbuf, int game, int currentEnt
int x, y;
int pointer[2] = {0, 0};
char* page = (char*)malloc(10 * sizeof(char));
bool isKor = (pkmnbuf[0xE3] == 0x08) ? true : false;

u8* pkmn = (u8*)malloc(PKMNLENGTH * sizeof(u8));
if (currentEntry < 30)
Expand Down Expand Up @@ -1575,10 +1576,10 @@ void printPKBank(u8* bankbuf, u8* mainbuf, u8* pkmnbuf, int game, int currentEnt
if (type1 != type2)
sf2d_draw_texture_part(typesSheet, 325, 120, 50 * type2, 0, 50, 18);

/*wchar_t *nick = (wchar_t*)malloc(NICKNAMELENGTH);
u32 nick[NICKNAMELENGTH*2];
memset(nick, 0, NICKNAMELENGTH*2);
getNickname(pkmn, nick);
sftd_draw_wtext(unicode12, 273, 69, WHITE, 12, nick);
free(nick);*/
sftd_draw_wtext((isKor) ? unicodeKOR12 : unicodeJPN12, 273, 69, WHITE, 12, (wchar_t*)nick);

char* level = (char*)malloc(8 * sizeof(char));
snprintf(level, 8, "Lv.%u", getLevel(pkmn));
Expand All @@ -1593,10 +1594,10 @@ void printPKBank(u8* bankbuf, u8* mainbuf, u8* pkmnbuf, int game, int currentEnt

free(level);

char *ot_name = (char*)malloc(0x17 * sizeof(char));
getOT(pkmn, ot_name);
sftd_draw_text(fontBold12, 273, 146, WHITE, 12, ot_name);
free(ot_name);
u32 ot_name[NICKNAMELENGTH*2];
memset(ot_name, 0, NICKNAMELENGTH*2);
getNickname(pkmn, ot_name);
sftd_draw_wtext((isKor) ? unicodeKOR12 : unicodeJPN12, 273, 146, WHITE, 12, (wchar_t*)ot_name);

char* otid = (char*)malloc(12 * sizeof(char));
snprintf(otid, 12, "ID. %u", getOTID(pkmn));
Expand Down Expand Up @@ -1761,7 +1762,9 @@ void printSettings(int box, bool speedy) {

void printfHexEditorInfo(u8* pkmn, int byte) {
int y = 70, x = 8;
char string[NICKNAMELENGTH];
bool isKor = (pkmn[0xE3] == 0x08) ? true : false;
u32 string[NICKNAMELENGTH*2];
memset(string, 0, NICKNAMELENGTH*2);

switch (byte) {
case 0x08 :
Expand Down Expand Up @@ -1804,8 +1807,8 @@ void printfHexEditorInfo(u8* pkmn, int byte) {
case 0x8D :
case 0x8E :
case 0x8F :
getHTName(pkmn, string);
sftd_draw_textf(fontBold12, x, y, LIGHTBLUE, 12, "Held Trainer: %s", string);
getNickname(pkmn, string);
sftd_draw_wtext((isKor) ? unicodeKOR12 : unicodeJPN12, x, y, WHITE, 12, (wchar_t*)string);
break;
}
}
94 changes: 72 additions & 22 deletions source/hex.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,38 +174,88 @@ void fillDescriptions(char *descriptions[]) {

descriptions[0xA8] = "Held Trainer TextVar, byte 1";
descriptions[0xA9] = "Held Trainer TextVar, byte 2";
descriptions[0xAE] = "Fullness";
descriptions[0xAF] = "Enjoyment";

descriptions[0xB0] = "Original Trainer Name, byte 1";
descriptions[0xB1] = "Original Trainer Name, byte 2";
descriptions[0xB2] = "Original Trainer Name, byte 3";
descriptions[0xB3] = "Original Trainer Name, byte 4";
descriptions[0xB4] = "Original Trainer Name, byte 5";
descriptions[0xB5] = "Original Trainer Name, byte 6";
descriptions[0xB6] = "Original Trainer Name, byte 7";
descriptions[0xB7] = "Original Trainer Name, byte 8";
descriptions[0xB8] = "Original Trainer Name, byte 9";
descriptions[0xB9] = "Original Trainer Name, byte 10";
descriptions[0xBA] = "Original Trainer Name, byte 11";
descriptions[0xBB] = "Original Trainer Name, byte 12";
descriptions[0xBC] = "Original Trainer Name, byte 13";
descriptions[0xBD] = "Original Trainer Name, byte 14";
descriptions[0xBE] = "Original Trainer Name, byte 15";
descriptions[0xBF] = "Original Trainer Name, byte 16";

descriptions[0xC0] = "Original Trainer Name, byte 17";
descriptions[0xC1] = "Original Trainer Name, byte 18";
descriptions[0xC2] = "Original Trainer Name, byte 19";
descriptions[0xC3] = "Original Trainer Name, byte 20";
descriptions[0xC4] = "Original Trainer Name, byte 21";
descriptions[0xC5] = "Original Trainer Name, byte 22";
descriptions[0xC6] = "Original Trainer Name, byte 23";
descriptions[0xC7] = "Original Trainer Name, byte 24";

descriptions[0xCA] = "Original Trainer Friendship";
descriptions[0xCB] = "Original Trainer Affection";
descriptions[0xCC] = "Original Trainer Intensity";
descriptions[0xCD] = "Original Trainer Memory";
descriptions[0xCE] = "Original Trainer TextVar";

descriptions[0xD0] = "Original Trainer Feeling";
descriptions[0xD1] = "Egg Year";
descriptions[0xD2] = "Egg Month";
descriptions[0xD3] = "Egg Day";
descriptions[0xD4] = "Met Year";
descriptions[0xD5] = "Met Month";
descriptions[0xD6] = "Met Day";

descriptions[0xD8] = "Egg Location";
descriptions[0xDA] = "Met Location";

descriptions[0xDC] = "Ball";
descriptions[0xDD] = "Met Level / Original Trainer Gender";
descriptions[0xDE] = "Hyper Train Flags";
descriptions[0xDF] = "Version";

descriptions[0xE0] = "Country";
descriptions[0xE1] = "Region";
descriptions[0xE2] = "Console Region";
descriptions[0xE3] = "Language";
}

void fillSectors(bool sector[][2]) {
// editable, requires Boolean
for (int j = 0; j < PKMNLENGTH; j++) {
sector[j][0] = false;
sector[j][1] = false;
}

// editable, requires Boolean
sector[0x00][0] = true; // encryption constant byte1
sector[0x01][0] = true; // encryption constant byte2
sector[0x02][0] = true; // encryption constant byte3
sector[0x03][0] = true; // encryption constant byte4
for (int j = 0x00; j <= 0x03; j++) // encryption constant
sector[j][0] = true;

sector[0x0A][0] = true; // item byte1
sector[0x0B][0] = true; // item byte2
sector[0x0C][0] = true; // TID byte1
sector[0x0D][0] = true; // TID byte2
sector[0x0E][0] = true; // SID byte1
sector[0x0F][0] = true; // SID byte2

sector[0x18][0] = true; // PID byte1
sector[0x19][0] = true; // PID byte2
sector[0x1A][0] = true; // PID byte3
sector[0x1B][0] = true; // PID byte4
for (int j = 0x0A; j <= 0x0F; j++) // species to sid
sector[j][0] = true;

//sector[0x1D][0] = true; sector[0x1D][1] = true; // fateful encounter
for (int j = 0x18; j <= 0x1B; j++) // pid
sector[j][0] = true;

for (int j = 0x1E; j <= 0x2A; j++) // EV_HP to Pelago Status
sector[0xDC][0] = true; // Ball

for (int j = 0x40; j <= 0x57; j++) // Nickname
sector[j][0] = true;

for (int j = 0x1E; j <= 0x29; j++) // EV_HP to Contest Value Sheen
sector[j][0] = true;

for (int j = 0x62; j <= 0x69; j++) // Move1_PP to Move4_PPUps
for (int j = 0x5A; j <= 0x71; j++) // Move 1 to Relearn Move 4
sector[j][0] = true;

for (int j = 0x78; j <= 0x8F; j++) // Held Trainer Name
Expand All @@ -217,12 +267,12 @@ void fillSectors(bool sector[][2]) {
for (int j = 0xAE; j <= 0xAF; j++) // Fullness to Enjoyment
sector[j][0] = true;

for (int j = 0xCA; j <= 0xCD; j++) // OT_Friendship to OT_Memory
for (int j = 0xB0; j <= 0xC7; j++) // OT Name
sector[j][0] = true;

for (int j = 0xD0; j <= 0xD6; j++) // OT_Feeling to Met Day
for (int j = 0xCA; j <= 0xCD; j++) // OT_Friendship to OT_Memory
sector[j][0] = true;

for (int j = 0xDF; j <= 0xE3; j++) // Version to Language
for (int j = 0xD0; j <= 0xD6; j++) // OT_Feeling to Met Day
sector[j][0] = true;
}

0 comments on commit ce692e6

Please sign in to comment.