Skip to content

Commit

Permalink
fix issues with hex editor
Browse files Browse the repository at this point in the history
  • Loading branch information
BernardoGiordano committed Jul 14, 2018
1 parent 42a1ab9 commit f3bc07c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PRODUCT_CODE := CTR-HB-PKSM

VERSION_MAJOR := 5
VERSION_MINOR := 1
VERSION_MICRO := 3
VERSION_MICRO := 4

ROSALINA := 1

Expand Down
56 changes: 45 additions & 11 deletions source/editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,20 +536,54 @@ void pokemonEditor(u8* mainbuf) {
pkx_set_flag(pkmn, 0x1D, 0, !((pkmn[byteEntry] & 1) == 1));
}
}

u8 byte = 0;
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 5; x++) {
if ((hidKeysDown() & KEY_TOUCH) && touch.px > 42 + x*50 && touch.px < 77 + x*50 && touch.py > 90 + y*32 + y*2 && touch.py < 110 + y*32) {
byte = byteLookup[y][x];
pkmn[byteEntry] = createByte(byte, pkmn[byteEntry]);
else if (sector[byteEntry][0]) {
bool downPlus = hidKeysDown() & KEY_A;
bool downMinus = hidKeysDown() & KEY_X;
bool heldPlus = hidKeysHeld() & KEY_A;
bool heldMinus = hidKeysHeld() & KEY_X;

if (heldMinus && heldPlus)
speed = 0;
else if (downMinus) {
if (pkmn[byteEntry] > 0)
pkmn[byteEntry]--;
}
else if (heldMinus) {
if (speed < -30 && pkmn[byteEntry] > 0)
pkmn[byteEntry]--;
else
speed--;
}
else if (downPlus) {
if (pkmn[byteEntry] < 0xFF)
parseHexEditor(pkmn, byteEntry);
}
else if (heldPlus) {
if (speed > 30 && pkmn[byteEntry] < 0xFF)
parseHexEditor(pkmn, byteEntry);
else
speed++;
}
else
speed = 0;

u8 byte = 0;
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 5; x++) {
if ((hidKeysDown() & KEY_TOUCH) && touch.px > 42 + x*50 && touch.px < 77 + x*50 && touch.py > 90 + y*32 + y*2 && touch.py < 110 + y*32) {
byte = byteLookup[y][x];
pkmn[byteEntry] = createByte(byte, pkmn[byteEntry]);
}
}
}

if ((hidKeysDown() & KEY_TOUCH) && touch.px > 192 && touch.px < 227 && touch.py > 186 && touch.py < 206) {
byte = 0x0;
pkmn[byteEntry] = createByte(byte, pkmn[byteEntry]);
}
}
if ((hidKeysDown() & KEY_TOUCH) && touch.px > 192 && touch.px < 227 && touch.py > 186 && touch.py < 206) {
byte = 0x0;
pkmn[byteEntry] = createByte(byte, pkmn[byteEntry]);
}



printPKEditor(pkmn, byteEntry, 0, 0, ED_HEX, descriptions);
}
Expand Down
4 changes: 2 additions & 2 deletions source/graphic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1543,12 +1543,12 @@ void printfHexEditorInfo(u8* pkmn, int byte) {
case 0x0C :
case 0x0D :
pp2d_draw_wtextf(x, y, FONT_SIZE_12, FONT_SIZE_12, LIGHTBLUE, i18n(S_GRAPHIC_HEXEDITOR_TID), pkx_get_tid(pkmn));
pp2d_draw_textf(x, y + 16, FONT_SIZE_12, FONT_SIZE_12, LIGHTBLUE, "Gen7 TID: %d", ((unsigned int)(pkx_get_tid(pkmn) + pkx_get_sid(pkmn)*65536) % 1000000));
pp2d_draw_textf(x + 152, y, FONT_SIZE_12, FONT_SIZE_12, LIGHTBLUE, "Gen7 TID: %d", ((unsigned int)(pkx_get_tid(pkmn) + pkx_get_sid(pkmn)*65536) % 1000000));
break;
case 0x0E :
case 0x0F :
pp2d_draw_wtextf(x, y, FONT_SIZE_12, FONT_SIZE_12, LIGHTBLUE, i18n(S_GRAPHIC_HEXEDITOR_SID), pkx_get_sid(pkmn));
pp2d_draw_textf(x, y + 16, FONT_SIZE_12, FONT_SIZE_12, LIGHTBLUE, "Gen7 TID: %d", ((unsigned int)(pkx_get_tid(pkmn) + pkx_get_sid(pkmn)*65536) % 1000000));
pp2d_draw_textf(x + 152, y, FONT_SIZE_12, FONT_SIZE_12, LIGHTBLUE, "Gen7 TID: %d", ((unsigned int)(pkx_get_tid(pkmn) + pkx_get_sid(pkmn)*65536) % 1000000));
break;
case 0x14 :
pp2d_draw_wtextf(x, y, FONT_SIZE_12, FONT_SIZE_12, LIGHTBLUE, i18n(S_GRAPHIC_HEXEDITOR_ABILITY), abilities[pkx_get_ability(pkmn)]);
Expand Down

0 comments on commit f3bc07c

Please sign in to comment.