Homebrew [WIP] PHBank - Pokémon Homebrew Bank

shinyquagsire23

SALT/Sm4sh Leak Guy
Member
Joined
Nov 18, 2012
Messages
1,977
Trophies
2
Age
26
Location
Las Vegas
XP
3,765
Country
United States
Since I didn't understand anything after the interrogation mark,
I'll just say that I used a spritesheet converted to c-source with GIMP.
Basically my point was that you could load resources from the game who's save you're editing (ie load the resources from Omega Ruby, X, Y, etc) rather than importing your own spritesheet. It would be tricky at first, but in the long run well worthwhile because it would be forwards compatible.
 

Ekaitz

Redhead Believer
Member
Joined
Jun 13, 2010
Messages
608
Trophies
0
XP
441
Country
France
Merci beaucoup!

Great work, really. I'm just waiting for the auto-completion to complete my OR Pokedex. (I've got everything in Pokemon X, just waiting for a transfer)
 

suloku

Well-Known Member
Member
Joined
Apr 28, 2008
Messages
883
Trophies
0
XP
866
Country
By the way, I haven't tested it yet, but I assume the bank data are box bin files compatible with pkhex? That would be great.

About resources... are there really legal issues to include them in a non-lucrative project? They are everywhere in the net (bulbapedia, serebii...) and in many years I don't think nintendo has sued them for using that data.

Merci beaucoup!

Great work, really. I'm just waiting for the auto-completion to complete my OR Pokedex. (I've got everything in Pokemon X, just waiting for a transfer)
Why don't you use pkHex? Dump all boxes and load them in your OR save.
 
  • Like
Reactions: Deleted-236924

lemanuel

Maxconsole's All-Knowing Lurker
Member
Joined
Dec 11, 2014
Messages
2,095
Trophies
0
XP
1,254
Country
Portugal
About resources... are there really legal issues to include them in a non-lucrative project? They are everywhere in the net (bulbapedia, serebii...) and in many years I don't think nintendo has sued them for using that data.

When that non-lucrative project is a free alternative to the paid solution that's already been done by them, I think they would mind :P
 

suloku

Well-Known Member
Member
Joined
Apr 28, 2008
Messages
883
Trophies
0
XP
866
Country
When that non-lucrative project is a free alternative to the paid solution that's already been done by them, I think they would mind :P

It's nothing you can't do with pkhex and a computer, you could have multiple savegames and use their 31 boxes as a bank; having it in the 3DS just makes it more convenient.

EDIT: or just have box bin files, but having it in savegames makes browsing easier.

This is a little offtopic, so you might stop reading:
Also, IMHO pokemon bank should be a one-time paid solution and offline, or at the very least poketransfer should. Paying to transfer genV to genVI...
And there's no point in the bank being cloud storage since you can't access it from any other 3DS, the only advantage is the unlikely outcome of losing your 3ds or accidentally formatting it...

I guess the true advantage will be when gen VII appears, since the transfer will probably be done as batch, but if gen VII pokemon aren't as gen VI they might just pull of a different app for genVII and make us pay again...
 
Last edited by suloku,

lemanuel

Maxconsole's All-Knowing Lurker
Member
Joined
Dec 11, 2014
Messages
2,095
Trophies
0
XP
1,254
Country
Portugal
It's nothing you can't do with pkhex and a computer, you could have multiple savegames and use their 31 boxes as a bank; having it in the 3DS just makes it more convenient.

This is a little offtopic, so you might stop reading:
Also, IMHO pokemon bank should be a one-time paid solution and offline, or at the very least poketransfer should. Paying to transfer genV to genVI...
And there's no point in the bank being cloud storage since you can't access it from any other 3DS, the only advantage is the unlikely outcome of losing your 3ds or accidentally formatting it...

I guess the true advantage will be when gen VII appears, since the transfer will probably be done as batch, but if gen VII pokemon aren't as gen VI they might just pull of a different app for genVII and make us pay again...

I agree completely with your opinion. That's why I'm a big supporter of this project.
And yeah, it's possible to do it with other means but that doesn't mean they couldn't be against it just the same.
 

Kurt91

Well-Known Member
Member
Joined
Sep 9, 2012
Messages
589
Trophies
1
Age
33
Location
Newport, WA
XP
2,235
Country
United States
Do you think it would ever be possible to read data from earlier games? I've got a ROM of Pokemon Red and Crystal that I'd like to consolidate everything together. (I wanted to start from the first games and compile all of my Pokemon into one massive set. Unfortunately, writing down stats manually for PokeSav/PokeGen is tedious as hell.)
 

duwen

Old Man Toad
Member
Joined
Sep 6, 2013
Messages
3,191
Trophies
2
Location
Bullet Hell
Website
www.exophase.com
XP
4,295
Country
United Kingdom
Do you think it would ever be possible to read data from earlier games? I've got a ROM of Pokemon Red and Crystal that I'd like to consolidate everything together. (I wanted to start from the first games and compile all of my Pokemon into one massive set. Unfortunately, writing down stats manually for PokeSav/PokeGen is tedious as hell.)
You might want to take a look at this... once you've transferred them up to gen III you can then use A-save to save the contents of all boxes as .pkm files and import them directly to gen VI with PKHeX.
 

Gocario

GBAFail'd
OP
Member
Joined
Sep 5, 2015
Messages
640
Trophies
0
Location
Bourg Palette
XP
804
Country
France
By the way, I haven't tested it yet, but I assume the bank data are box bin files compatible with pkhex? That would be great.
I don't encrypt the Pokémon in the Bank (waste of time). That means that Pokémon in PC are stored as .ek6 and Pokémon in Bank are stored as .pk6!
I am using this type of file format for the Bankdata.
Code:
### [Bank] Bankdata

| Offset (hex) | Size (byte) | Description |
| ------------ | ----------- | ----------- |
| 0x0          | 0x4         | Version     |
| 0x4          | 0xfc        | *Unknow*    |
| 0x100        | 0xa9ec0     | Bank        |
| 0xa9fc0      | 0x40        | *Unknow*    |


I tried to understand the Pokédex data logic using PKHex source.
For anyone who worked on Pokédex data, am I right with those offsets?
Code:
## [Save] Pokédex

| Offset (hex & bit) | Size (bit) | Description |
| ------------------ | ---------- | ----------- |
| ...                | ...        | ...         |
| 0x008 & 0b00000001 | 0b1        | Owned (1) for Pokémon 001 |
| 0x008 & 0b00000010 | 0b1        | Owned (1) for Pokémon 002 |
| 0x008 & 0b00000100 | 0b1        | Owned (1) for Pokémon 003 |
| 0x008 & 0b00001000 | 0b1        | Owned (1) for Pokémon 004 |
| ...                | ...        | ...                       |
| 0x067 & 0b00010000 | 0b1        | Owned (1) for Pokémon 765 |
| 0x067 & 0b00100000 | 0b1        | Owned (1) for Pokémon 766 |
| 0x067 & 0b01000000 | 0b1        | Owned (1) for Pokémon 767 |
| 0x067 & 0b10000000 | 0b1        | Owned (1) for Pokémon 768 |
| 0x068 & 0b00000001 | 0b1        | Owned Male (2) for Pokémon 001   |
| ...                | ...        | ...                              |
| 0x0c7 & 0b10000000 | 0b1        | Owned Male (2) for Pokémon 768   |
| 0x0c8 & 0b00000001 | 0b1        | Owned Female (3) for Pokémon 001 |
| ...                | ...        | ...                              |
| 0x127 & 0b10000000 | 0b1        | Owned Female (3) for Pokémon 768 |
| 0x128 & 0b00000001 | 0b1        | Owned Shiny Male (4) for Pokémon 001   |
| ...                | ...        | ...                                    |
| 0x187 & 0b10000000 | 0b1        | Owned Shiny Male (4) for Pokémon 768   |
| 0x188 & 0b00000001 | 0b1        | Owned Shiny Female (5) for Pokémon 001 |
| ...                | ...        | ...                                    |
| 0x247 & 0b10000000 | 0b1        | Owned Shiny Female (5) for Pokémon 768 |
| 0x248 & 0b00000001 | 0b1        | Encountered Male (6) for Pokémon 001   |
| ...                | ...        | ...                                    |
| 0x2a7 & 0b10000000 | 0b1        | Encountered Male (6) for Pokémon 768   |
| 0x2a8 & 0b00000001 | 0b1        | Encountered Female (7) for Pokémon 001 |
| ...                | ...        | ...                                    |
| 0x307 & 0b10000000 | 0b1        | Encountered Female (7) for Pokémon 768 |
| 0x308 & 0b00000001 | 0b1        | Encountered Shiny Male (8) for Pokémon 001   |
| ...                | ...        | ...                                          |
| 0x367 & 0b10000000 | 0b1        | Encountered Shiny Male (8) for Pokémon 768   |
| 0x368 & 0b00000001 | 0b1        | Encountered Shiny Female (8) for Pokémon 001 |
| ...                | ...        | ...                                          |
| 0x3c7 & 0b10000000 | 0b1        | Encountered Shiny Female (8) for Pokémon 768 |
| ...                | ...        | ...                                          |

## [Save] Pokédex lang

| Offset (hex & bit) | Size (bit) | Description |
| ------------------ | ---------- | ----------- |
| 0x000 & 0b00000001 | 0b1        | Japanese (1) for Pokémon 001 |
| 0x000 & 0b00000010 | 0b1        | English (2) for Pokémon 001  |
| 0x000 & 0b00000100 | 0b1        | French (3) for Pokémon 001   |
| 0x000 & 0b00001000 | 0b1        | Italian (4) for Pokémon 001  |
| 0x000 & 0b00010000 | 0b1        | German (5) for Pokémon 001   |
| 0x000 & 0b00100000 | 0b1        | Spanish (6) for Pokémon 001  |
| 0x000 & 0b01000000 | 0b1        | Korean (7) for Pokémon 001   |
| 0x000 & 0b10000000 | 0b1        | Japanese (1) for Pokémon 002 |
| 0x001 & 0b00000001 | 0b1        | English (2) for Pokémon 002  |
| 0x001 & 0b00000010 | 0b1        | French (3) for Pokémon 002   |
| 0x001 & 0b00000100 | 0b1        | Italian (4) for Pokémon 002  |
| 0x001 & 0b00001000 | 0b1        | German (5) for Pokémon 002   |
| 0x001 & 0b00010000 | 0b1        | Spanish (6) for Pokémon 002  |
| 0x001 & 0b00100000 | 0b1        | Korean (7) for Pokémon 002   |
| ...                | ...        | ...                          |

PS: Those templates are made to correspond to the github wiki format.
 

suloku

Well-Known Member
Member
Joined
Apr 28, 2008
Messages
883
Trophies
0
XP
866
Country
There's a gen 1-2-3 converter already, which is actually the way to go since it is a way that will always convert using the same rules: http://projectpokemon.org/forums/sh...r-Android-Gen-1-2-3-Full-Editor-and-Converter

edit: the guide you pointed out uses an old version of the same app I linked too, it was renamed to poketweet and more features were added

But, how do you expect to read gb cartriges in n3ds? And if you are talking about emulators, better do it on pc, it should be easier to manage huge amount of pokemon anyway (if you are thinking about reading emulator savefiles, i.e. gameyob).

I don't encrypt the Pokémon in the Bank (waste of time). That means that Pokémon in PC are stored as .ek6 and Pokémon in Bank are stored as .pk6!
I am using this type of file format for the Bankdata.
Oh, so banked pokemon are actually stored as individual files, that works too, pkhex boxes are just concatenated (pk6? ek&? dunno) pokemon files with 00 data for blank pokemon. I really need to test this.

About pokedex data, can't help with that, but I can test to set with your tool and see if the same is set in pkhex.
 
Last edited by suloku,

Gocario

GBAFail'd
OP
Member
Joined
Sep 5, 2015
Messages
640
Trophies
0
Location
Bourg Palette
XP
804
Country
France
Oh, so banked pokemon are actually stored as individual files, that works too, pkhex boxes are just concatenated (pk6? ek&? dunno) pokemon files with 00 data for blank pokemon. I really need to test this.

A Pokémon in PC is an array of 0xe8 (232) bytes.
A Pokémon in Party is an array of 0x104 (260) bytes (0xe8[PC] + 0x1c[BattleStats]).

Pokémon are modified by PKHex/PHBank while in pk6 form (Pokémon Gen 6).
Pokémon are stored in savedata in a ek6 form (Encrypted Pokémon Gen 6).
PKHex can import both filetype.

When I read the savedata:
  • I read the ek6 form (an array of 232 bytes), which are concatened with each others.
  • I decrypt them to get the pk6 form (an array of 232 bytes).
  • And I convert them to the pkm form, which is a struct containing data attributes.
When I read the bankdata:
  • I read the pk6 form (an array of 232 bytes), which are concatened with each others.
  • I convert them to the pkm form, which is a struct containing data attibutes.

When I write data, I just reverse those operations.
 

Kaphotics

badc0ded
Member
Joined
Sep 10, 2010
Messages
612
Trophies
0
XP
626
Country
United States
  • Like
Reactions: rainparadesamurai

Gocario

GBAFail'd
OP
Member
Joined
Sep 5, 2015
Messages
640
Trophies
0
Location
Bourg Palette
XP
804
Country
France

Kaphotics

badc0ded
Member
Joined
Sep 10, 2010
Messages
612
Trophies
0
XP
626
Country
United States
I saw this, but I didn't want to edit the buffer (savedata) during runtime.
The buffer should be modified only when saving.
Because I want the possibility to export a backup whenever I want.
Would the following solution be appropriate?:

When the sav is loaded, rip out the PokeDex block to a separate memory buffer.
When adding Pokemon, just treat "SaveGame.PokeDex" as 0 and set the bits of that buffer instead of the main save.
When writing the save, copy that buffer to the save and fix the checksum.
 

Gocario

GBAFail'd
OP
Member
Joined
Sep 5, 2015
Messages
640
Trophies
0
Location
Bourg Palette
XP
804
Country
France
Your solution is very good.
But I already planned to use structures to contains those data.
I think I have something to load/save data from savebuffer.
I just need to try out.
Code:
typedef struct dex_t
{
    bool owned;
    bool ownedMale;
    bool ownedFemale;
    bool ownedShinyMale;
    bool ownedShinyFemale;
    bool encounteredMale;
    bool encounteredFemale;
    bool encounteredShinyMale;
    bool encounteredShinyFemale;
    bool langJapanese;
    bool langEnglish;
    bool langFrench;
    bool langItalian;
    bool langGerman;
    bool langSpanish;
    bool langKorean;
    uint16_t dexNavLevel;
} dex_t;

typedef struct pokedex_t
{
    dex_t dexes[0x60 * 8]; // [PKM_COUNT]
} pokedex_t;
Edit using Bitfields:
Code:
typedef struct PACKED dex_t
{
    bool owned : 1;
    bool ownedMale : 1;
    bool ownedFemale : 1;
    bool ownedShinyMale : 1;
    bool ownedShinyFemale : 1;
    bool encounteredMale : 1;
    bool encounteredFemale : 1;
    bool encounteredShinyMale : 1;
    bool encounteredShinyFemale : 1;
    bool langJapanese : 1;
    bool langEnglish : 1;
    bool langFrench : 1;
    bool langItalian : 1;
    bool langGerman : 1;
    bool langSpanish : 1;
    bool langKorean : 1;
    unsigned : 0;
    uint16_t dexNavLevel : 16;
} dex_t;

typedef struct pokedex_t
{
    dex_t dexes[0x60 * 8]; // [PKM_COUNT]
} pokedex_t;
 
Last edited by Gocario,

Gocario

GBAFail'd
OP
Member
Joined
Sep 5, 2015
Messages
640
Trophies
0
Location
Bourg Palette
XP
804
Country
France
The alpha-release 0.3 is out.

This version auto-add the Pokémon transfered data to the Pokédex, only on OR/AS games (may not work properly!).
This version can transfer a whole box, swithing data with the other (eg: Swap all Pokémon from PC's 2nd Box with all Pokémon from Bank's 42th Box).
I made a new icon from "scratch", by keeping the Pokébank icon idea.

The alpha-release 0.3a is just a fix for the Pokédex AC to prevent a crash for XY users.

Disclaimer: ALWAYS make a backup!!
 
Last edited by Gocario,
  • Like
Reactions: RustInPeace

suloku

Well-Known Member
Member
Joined
Apr 28, 2008
Messages
883
Trophies
0
XP
866
Country
Great news, gonna try it right now!

EDIT: just tested and I noticed how long it takes to write the full bank file.
May I suggest having 100 files (1 for each bank) and keeping track of the ones that need to be updated? I don't think anyone would change more than 31 boxes at once, and that would also allow loading those files as boxes in pkhex as a secondary efect

Also, the upper screen log show an error message, but everything seems to work fine (will edit later with screenshot, don't have my 3ds now).

Finally, pokemon species of selected pokemon in the box is supossed to be shown? I don't see it.

And another suggestion while the textmode boxes are used (unless gui is comming soon): use "-" for an empty slot in a box, instead of showing 0 for all and X for the selected pokemon.

Edit2: what log screen says is
Init FS OK
ERROR...
ERROR...
 
Last edited by suloku,

Gocario

GBAFail'd
OP
Member
Joined
Sep 5, 2015
Messages
640
Trophies
0
Location
Bourg Palette
XP
804
Country
France
EDIT: just tested and I noticed how long it takes to write the full bank file.
May I suggest having 100 files (1 for each bank) and keeping track of the ones that need to be updated? I don't think anyone would change more than 31 boxes at once, and that would also allow loading those files as boxes in pkhex as a secondary efect
I might try but not now (Pokébank saving time is long too btw). :D

And another suggestion while the textmode boxes are used (unless gui is comming soon): use "-" for an empty slot in a box, instead of showing 0 for all and X for the selected pokemon.
Huumm, I'm working on GUI. :3

Also, the upper screen log show an error message, but everything seems to work fine (will edit later with screenshot, don't have my 3ds now).
Finally, pokemon species of selected pokemon in the box is supossed to be shown? I don't see it.
Edit2: what log screen says is
Init FS OK
ERROR...
ERROR...
Yes, it is supposed.
But it seems that the data are not read (located in /pkbank/data/en)...
I changed the message "ERROR..." in the current dev version.

Here is the github as promised: https://github.com/gocario/PHBank
 

daraly

Member
Newcomer
Joined
Sep 7, 2015
Messages
22
Trophies
0
Age
23
XP
88
Country
Switzerland
it can transfer Pokemon to ORAS from xy?like real Pokemon BANK. the Pokemon is illegal or not?
(as i know,transfer Pokemon to oras from xy,Pokemon met will change,will it like real Pokemon bank service?)
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Veho @ Veho: Firefox users be like "look at what they have to do to mimic a fraction of our power."