Commit Graph

57 Commits

Author SHA1 Message Date
Philippe Symons
9a80247c30 Fix crash with Gen1GameReader::setTrainerMoney 2026-02-10 21:57:35 +01:00
Philippe Symons
4ca381bb61 Add setMoney example executable 2026-02-10 21:04:48 +01:00
Philippe Symons
06f894d52c
Merge pull request #8 from risingPhil/feature/support-trainer-money
Support reading and writing the trainers' money from the save file.
2026-02-04 13:08:59 +01:00
Philippe Symons
54d9caa6c2 Support reading and writing the trainers' money from the save file.
It was implemented to be used for the Pokéshop idea for PokeMe64
2026-01-14 18:49:37 +01:00
Philippe Symons
8bb1f6a7d3 Fixing injecting pokémon into japanese gen I pc boxes 2026-01-07 22:05:03 +01:00
Philippe Symons
ec8b35687d Fix Japanese Celebi distribution event pokemon label 2026-01-07 21:11:21 +01:00
Philippe Symons
0cdc309e97 Fix EGG nickname for Japanese games 2026-01-07 20:58:00 +01:00
Philippe Symons
d748a95517 Fix Thrash Swipe Machop 2026-01-07 20:48:52 +01:00
Philippe Symons
aedb58832c
V0.3 (#7)
* Feature/add support for localized versions (#3)

* Add support for gen I localizations

There currently is no way to automatically detect the localization yet though.

* Add gen1_determineGameLanguage() and use it automatically in Gen1GameReader if not specified in the constructor

* Add support for the gen II localizations

Note: for Korean games, specifically, I did not implement the Korean character set
(nor do I plan to)

The reason is that it is entirely different and more complex to implement than the other
character sets. I'm not personally invested nor interested enough to go through the hassle.

This affects the pokémon names that will be displayed when using libpokemegb. Instead as
a fallback, it will return "poke-<number>" for these roms.

Feel free to contribute proper Korean character set (and pokémon names) support!

* Streamline the Gen I localization code to be structured similarly to the gen II's

* Fix bug

When Gen1GameReader is triggering the language detection automatically, the
Gen1IconDecoder instance is not updated with the detected language

* Update README.md

* Fix markdown special char escape problem in README.md

* Fix name decoding for localizations

* Fix detection of German Pokémon Yellow

* Fix bug: Japanese saves were not detected correctly for gen I

* Convert every character map entry into UTF-8.

libdragon requires every string to be in UTF-8 encoding

* Fix bug with Japanese saves. Wrong offset was used for the party storage in several functions

* Fix OT names and nicknames for Japanese cartridges

* Fix another issue with Gen I nicknames. Gen II is also still entirely broken in this regard

* Also fix Japanese pokemon name retrieval in gen I

* Fix OT and nicknames for Japanese gen I games

* Add support for Japanese and Korean Gen II save offsets

Japenese and Korean Gen II saves have a different save structure (data at different offsets)

* Disable save corruption check for Japanese/Korean games.

I don't have the right save offsets nor can find them. (I'm not adept at decompilation myself and pokegold/pokecrystal don't have the japanese offsets. Nor does PkHex)

* Refactor the gen1 related code to store the different SRAM offsets for gen 1 saves similarly as we do for gen 2

* Remove unnecessary casts

* Avoid trying to decode Korean trainername and rival name.

We don't support the character set, neither in libpokemegb and PokeMe64.

The Korean character set is a lot more complex than the other ones. But it would also require the inclusion of a lot of additional character glyphs in PokeMe64
in order to show the characters. Right now I don't feel like doing that for a localization that won't be used by many in combination with PokeMe64.

So instead of showing the trainer name and rival name, I will just replace it with "player" and "rival". It's not an amazing solution, but it's the best I'm willing to do for now.

* Add support for the Korean character sets.

This was needed after all, because we don't want injected pokémon on a Korean cartridge to end up having a nickname like "poke-<indexnumber>".
So that implies the need for being able to decode and encode pokémon names in Korean.

So yeah, I bit the bullet and added support for it. This was really annoying to do, but it has been done!

* Feature/add japanese distribution pokemon (#4)

* Add Gen I Japanese Distribution Event Pokémon

* Remove external definitions of each individual distribution pokémon from the headers and make them static in the source file

* Add isJapanese field to Gen2DistributionPokemon struct and adapt every existing definition

* Fix mistake in last commit

* Make sure the OT name is replaced when dealing with Japanese distribution pokémon on a different language cart and vice versa

* Add Japanese Mystery Egg #3 gen II  event distribution Pokémon

* Add remaining Japanese Event Distribution Pokémon

* Fix another issue with Gen I nicknames. Gen II is also still entirely broken in this regard

* Fix OT and nicknames for Japanese gen I games

* Refactor the gen1 related code to store the different SRAM offsets for gen 1 saves similarly as we do for gen 2

* Bugfix/fix distribution event pokemon inconsistencies (#5)

* Add Gen I Japanese Distribution Event Pokémon

* Remove external definitions of each individual distribution pokémon from the headers and make them static in the source file

* Add isJapanese field to Gen2DistributionPokemon struct and adapt every existing definition

* Fix mistake in last commit

* Make sure the OT name is replaced when dealing with Japanese distribution pokémon on a different language cart and vice versa

* Add Japanese Mystery Egg #3 gen II  event distribution Pokémon

* Add remaining Japanese Event Distribution Pokémon

* Fix another issue with Gen I nicknames. Gen II is also still entirely broken in this regard

* Fix OT and nicknames for Japanese gen I games

* Refactor the gen1 related code to store the different SRAM offsets for gen 1 saves similarly as we do for gen 2

* Fix some inconsistencies with Gen II distribution event pokémon.

* Make use of the Move enum instead of magic numbers for the pokémon moves (#6)

* Add Gen1GameReader::getCurrentMap() function to retrieve the current map the player is on.

I may be able to use this when adding a move deleter for gen1 games later, to make sure the player is in the pokemon center.
(to make sure the player doesn't get trapped because he/she would delete an HM move)

* Fix broken Japanese PC Box support + add support for Pokémon Green (JPN) + fix currentMap retrieval on japanese saves

So, turns out that PC Box support was entirely broken for the Japanese games with PokeMe64.

Apparently, the japanese games only have 8 boxes instead of 12, but each of them has a capacity of 30 pokémon instead
of 20!

So that changes things for the save offsets.

Also: the currentMap offset was wrong for Japanese games. So I had to fix that too!

* Updated README.md

* Fix the same issue with PC Boxes for Japanese Gen II games.

The international releases have 14 pc boxes with 20 pokemon each. But the japanese gen II games have 9 pc boxes with 30 entries each.

* Rework rom offsets for pokémon blue to avoid duplicate rom offset definitions.

The only one different from the red/green offsets is the japanese one anyway.

* Replace "PokeMe64" OT with "PM64" when injecting japanese mons into international games.

Turns out the official character limit was 7

* Fill the unused bytes of a nickname with the terminator byte.

This is needed because according to Bulbapedia, a nickname is only considered not a nickname if it matches with the
uppercase species name with all unused bytes set to the 0x50 terminator.

* Add gen1_isAPokeCenter() function
2025-02-17 12:38:21 +01:00
Philippe Symons
f31f31deff
Feature/integrate resetrtc (#2)
* Move resetRtc functionality to libpokemegb

I'll need to use it in 2 places in PokeMe64 and this will allow me to reuse code

* Forgot to commit this line
2024-12-06 16:05:54 +01:00
Philippe Symons
2ba33f26f7 Cleanup dead code 2024-10-08 12:50:48 +02:00
Philippe Symons
09bc97bce3 Forgot to also change Gen2GameReader::getPokemonIconType() 2024-10-08 12:49:37 +02:00
Philippe Symons
095b15227e
Bugfix/pm64 10 sprites error pokemon silver (#1)
Fix PokeMe64 bug #10 - Sprites error Pokemon Silver

Turns out that Pokemon Silver has the IconPointers list at a different rom offset for some reason.

This was an oversight during my testing because I don't personally own Pokemon Silver.

Fix: Use the right rom offset
2024-10-08 12:28:12 +02:00
risingPhil
feff0c5327 Fix double Bite Lapras entry 2024-09-30 17:27:41 +02:00
risingPhil
7f9456c751 Fix Shiny Ho-oh 2024-09-30 17:11:05 +02:00
risingPhil
bd518d0d87 Fix GameReader::decodePokemonIcon() API inconsistency in relation to decodeSprite() 2024-09-25 22:15:46 +02:00
risingPhil
a44b908587 Implement gen 2 party icon decoding
Now you can also decode the party icons for the gen 2 pokémon games
2024-09-25 20:22:17 +02:00
risingPhil
04bc493c03 Add Gen1GameReader::getPokemonIconType() 2024-09-24 22:52:26 +02:00
Philippe Symons
5d8209ba54 Improve comments 2024-09-24 12:32:01 +02:00
Philippe Symons
2643a00ca7 Add party icon decoding for gen 1 pokémon games.
Now you can decode the pokemon mini sprites/party icons from the rom into an RGB/RGBA buffer
2024-09-24 12:21:35 +02:00
Philippe Symons
de5381da81 Add code to consider an empty (zero'd out) save as an invalid checksum
The gen 2 saves contain 2 markers per section (main/backup) to serve as canary values to see whether an actual save is stored.
Because after all: checksum 0 is a valid checksum in some cases. So to distinguish between a valid and a corrupted save, these markers are used.

And now we use it too! This will be necessary to detect that there's no save file in case the save was wiped (or a reproduction cart is used)
2024-09-11 12:28:11 +02:00
risingPhil
33b4f9ce2f Fix trainerId generation for Pokemon Fun Fest Celebi. Should be below 1000 2024-08-23 01:41:42 +02:00
risingPhil
47ec404aac Fix bug and make unknown move (or moveIndex 0) return an empty string in getMoveString() 2024-08-13 20:56:50 +02:00
Philippe Symons
0fd91fb8e5 Move the application of the GenXDistributionPokemon properties to separate functions
This allows us to use the genx_prepareDistributionPokemon() functions followed by GenXGameReader::addPokemon()
instead of GenXGameReader::addDistributionPokemon() in order to actually show the resulting GenXTrainerPokemon in
a stats screen in PokeMe64. After all: the genx_prepareDistributionPokemon() function does things like generate IV,
decide the trainer OT name and ID and apply shinyness chances.

So when showing the resulting pokemon in a stats screen, we need the actual resulting pokemon in order to show the right
stats, OT and shinyness
2024-08-13 12:45:10 +02:00
risingPhil
7b96cae992 Do the same fix for gen 1 SpriteRendering for RGBA32 2024-08-09 14:08:09 +02:00
Philippe Symons
816c4ea679 Merge branch 'main' of github.com:risingPhil/libpokemegb 2024-08-09 11:33:46 +02:00
risingPhil
044bb1f6e3 Merge branch 'main' of github.com:risingPhil/libpokemegb into main 2024-08-09 12:53:41 +02:00
risingPhil
bb3d88172d Fix Endianness issues with sprite decoding
Sprite decoding was broken on Big Endian CPUs (such as AMD or the Nintendo 64 MIPS CPU), while working
on Little Endian CPUs (Intel): the color palettes came out wrong because they were stored as little endian.

Now we byte swap the 16-bit colors when reading them from the rom/cartridge if running on a big endian CPU, which
solves the issue (while still remaining compatible with Little Endian CPUs)
2024-08-09 12:50:05 +02:00
Philippe Symons
7f3e944420 Fix SpriteRenderer::removeBackground for gen 1 on RGBA16 2024-08-09 11:33:13 +02:00
Philippe Symons
2136e90bde Fix compiler warnings 2024-08-08 21:45:51 +02:00
risingPhil
bd95cc3ef8 Fix SpriteRenderer comments after latest changes 2024-08-07 21:52:16 +02:00
risingPhil
27fead0df0 Add the removeBackground functionality for RGBA16 as well (untested though) 2024-08-07 21:50:36 +02:00
risingPhil
e5342451ce Add more SpriteRenderer output formats and move the removeBackground functionality
- Add SpriteRenderer::OutputFormat::RGBA32 and SpriteRenderer::OutputFormat::RGBA16
- Move the removeBackground functionality out of the decodeSprite example application and into SpriteRenderer. It's RGBA32 only though
2024-08-07 21:11:55 +02:00
risingPhil
a43345317b Add some example code to the decodeSprite example application to remove the white background from a Sprite 2024-08-07 12:55:24 +02:00
risingPhil
c9257d7e01 Change unlockGsBallEvent() significantly.
Now it not only unlocks the event, but it also makes it repeatable by removing the GS Ball from the players' inventory first
and resetting all GS Ball related event flags.

Not only does this cover up my screw up with PokeMe64. (it prevents players from having to create a new save
to get access to the GS Ball event if they used one of my previous versions of PokeMe64)

As a bonus, it also makes the event completely repeatable, which is nice!
2024-07-29 01:11:13 +02:00
risingPhil
4a3bc9de18 Add functionality to get and set event flags 2024-07-29 00:51:54 +02:00
risingPhil
80e8397b93 Add functionality to remove an item and 2 example programs to add or remove an item. 2024-07-28 22:57:59 +02:00
risingPhil
99e495dad9 Add an API in Gen2GameReader to unlock the GS Ball event 2024-07-26 23:13:24 +02:00
risingPhil
7ac7c29f3e Merge branch 'main' of github.com:risingPhil/libpokemegb into main 2024-07-26 21:54:02 +02:00
risingPhil
5b85c04b5a Fix gen1 bug reported by /u/imranFZakhaev
When adding a pokémon to a save with a full party, the behaviour is completely broken.

Not only did we add a pokémon to every box, but it also would be a completely different one or even crash the game when trying to access the box.

Fixes:

- Stop after adding a pokemon to a box. Don't add it to all.
- In commit 77d5d15 I added a ::setPokemon function and reworked the Gen1Box::add() function to use it. That's where it went wrong:

in the add() function, we would modify the number_of_pokemon counter of the box, but not manipulate the species list and write it.
Then in the setPokemon() function, we would read the box metadata and correct it because the number did not match the species list. This is what went wrong.

To fix it, I just had to modify the species list in the add() function as well again.
2024-07-26 21:49:39 +02:00
Philippe Symons
ce1714b74e Update README.md: now that PokeMe64 exists, I can link to it 2024-07-25 14:24:50 +02:00
Philippe Symons
b275d12a97 Also recalculate lvl in gen1_recalculatePokeStats 2024-07-25 10:40:08 +02:00
Philippe Symons
76ecc15ede Fix name bug with getMoveString 2024-07-23 23:50:07 +02:00
Philippe Symons
2adbacf43b Avoid performance hit in Gen1PlayerPokemonStorage
Make it possible for Gen1PlayerPokemonStorages' Gen1Party and Gen1Box to
avoid the performance hit in ::getPokemon caused by the recalculation of
the pokemons' level. This recalculation would read the pokemon stats
datastructure, which could be slow on the N64 transfer pak.
2024-07-23 23:40:19 +02:00
Philippe Symons
4fc77f27af Add getSpeciesAtIndex() function in Gen1PlayerPokemonStorage to enable
fast species type checking
2024-07-23 23:24:04 +02:00
risingPhil
8e569b9141 Fix capitalization 2024-07-23 22:54:53 +02:00
risingPhil
d5f5648c36 Add list of Pokémon moves in Moves.h alongside a function to convert the enum to string 2024-07-23 22:46:44 +02:00
risingPhil
77d5d152e9 add setPokemon() function in Gen1PlayerPokemonStorage. This is useful for updating existing pokémon 2024-07-23 13:50:37 +02:00
risingPhil
747bdd4b4b Fix bug gen2 addItem 2024-07-19 21:31:16 +02:00
risingPhil
20ba1f67fe More README.md 2024-06-11 22:14:34 +02:00