Skip to content

Commit

Permalink
Merge pull request #14 from kbembedded/code-refactor
Browse files Browse the repository at this point in the history
Refactor, UI update, Feature add
  • Loading branch information
EstebanFuentealba authored Sep 27, 2023
2 parents 50b4da1 + 35db373 commit 4522377
Show file tree
Hide file tree
Showing 69 changed files with 4,778 additions and 2,902 deletions.
Binary file modified .flipcorg/gallery/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .flipcorg/gallery/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .flipcorg/gallery/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .flipcorg/gallery/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .flipcorg/gallery/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 58 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

<div align="center">

**FW Official** | **FW Unleashed** | **FW RogueMaster**
:- | :- | :-
[![FlipC.org](https://flipc.org/EstebanFuentealba/Flipper-Zero-Game-Boy-Pokemon-Trading/badge?branch=main)](https://flipc.org/EstebanFuentealba/Flipper-Zero-Game-Boy-Pokemon-Trading?branch=main)|[![FlipC.org](https://flipc.org/EstebanFuentealba/Flipper-Zero-Game-Boy-Pokemon-Trading/badge?branch=main&firmware=unleashed)](https://flipc.org/EstebanFuentealba/Flipper-Zero-Game-Boy-Pokemon-Trading?branch=main&firmware=unleashed)|[![FlipC.org](https://flipc.org/EstebanFuentealba/Flipper-Zero-Game-Boy-Pokemon-Trading/badge?branch=main&firmware=roguemaster)](https://flipc.org/EstebanFuentealba/Flipper-Zero-Game-Boy-Pokemon-Trading?branch=main&firmware=roguemaster)
**FW Official** | **FW Unleashed** | **FW RogueMaster** | **FW Xtreme**
:- | :- | :- | :-
[![FlipC.org](https://flipc.org/EstebanFuentealba/Flipper-Zero-Game-Boy-Pokemon-Trading/badge?branch=main)](https://flipc.org/EstebanFuentealba/Flipper-Zero-Game-Boy-Pokemon-Trading?branch=main)|[![FlipC.org](https://flipc.org/EstebanFuentealba/Flipper-Zero-Game-Boy-Pokemon-Trading/badge?branch=main&firmware=unleashed)](https://flipc.org/EstebanFuentealba/Flipper-Zero-Game-Boy-Pokemon-Trading?branch=main&firmware=unleashed)|[![FlipC.org](https://flipc.org/EstebanFuentealba/Flipper-Zero-Game-Boy-Pokemon-Trading/badge?branch=main&firmware=roguemaster)](https://flipc.org/EstebanFuentealba/Flipper-Zero-Game-Boy-Pokemon-Trading?branch=main&firmware=roguemaster)|[![FlipC.org](https://flipc.org/EstebanFuentealba/Flipper-Zero-Game-Boy-Pokemon-Trading/badge?branch=main&firmware=xtreme)](https://flipc.org/EstebanFuentealba/Flipper-Zero-Game-Boy-Pokemon-Trading?branch=main&firmware=xtreme)
</div>

## Introduction
Expand All @@ -26,10 +26,10 @@ This project is intended to be overlayed on top of an existing firmware repo, i

- Clone the [Flipper Zero firmware repository](https://github.com/flipperdevices/flipperzero-firmware). Refer to [this tutorial](https://github.com/jamisonderek/flipper-zero-tutorials/tree/main/firmware/updating/README.md) for updating the firmware.
- Copy the "pokemon" folder into the `/applications_user/pokemon` folder in your firmware.
- Run the command `fbt launch_app` to run it on your Flipper Zero.
- Run the command `fbt launch` to run it on your Flipper Zero.

```bash
./fbt launch_app APPSRC=pokemon
./fbt launch APPSRC=pokemon
```

- NOTE: If you only want to generate the fap file, you must run the following command.
Expand All @@ -50,9 +50,9 @@ These instructions assume that you are starting at the Flipper Zero desktop. Oth

- Press the `OK` button on the Flipper to open the main menu.
- Choose `Applications` from the menu.
- Choose `Game Boy` from the submenu.
- Choose `GPIO` from the submenu.
- Choose `Pokemon Trading`
- The Flipper Zero should show the selection of Pokemon that you want to trade, and by default, it appears as bulbasaur.
- The Flipper Zero will show the main menu of the application. The first option is to select the Pokemon to trade.

<p align='center'>
<br />
Expand All @@ -62,74 +62,94 @@ These instructions assume that you are starting at the Flipper Zero desktop. Oth

- Press the `LEFT`/`RIGHT` buttons to paginate the selection of Pokemon by 1.
- Press the `UP`/`DOWN` buttons to paginate the selection of Pokemon by 10.
- Press the `OK` button to select the Pokemon to trade.
- Press the `OK` button to select the Pokemon to trade and return to the main menu

<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-2.png" width="400" /><br />
</p>

- The Flipper Zero should show the selection of the Pokemon's level that you want to trade, and by default, it appears as level 1.
- The traded Pokemon's nickname can be set. When a Pokemon is selected, the nickname defaults to the species name in all caps. This mimics a Pokemon without a customized nickname. In order to reset this nickname to its default, clear the text entry field, press `OK` on the `Save` button. This will fill the text box with the default name. Press `Save` again to set this name.
- **Note:** The Nidoran♀ and Nidoran♂ names will not properly render. This is because the Flipper currently cannot print unicode characters to screen. Following the above instructions will fill the text entry field with `NIDORAN ` with a space after it. This space is the unrenderable ♀/♂ symbol. Once traded, it will be correctly named.
- **Note:** Only alphanumeric characters are supported in the Pokemon's nickname at this time.

<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-1-1.png" width="400" />
<br />
</p>

- The Pokemon's level can be adjusted as well by hitting `OK` on the level option. The minimum level is `2` and the maximum is `100`. The level is input via a text box. (Levels below 2 cause an underflow glitch in Gen I games that would cause the level to jump to 100, so if you want this just set the Pokemon's level to 100)

<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-3.png" width="400" />
<br />
</p>

- Press the `LEFT`/`RIGHT` buttons to paginate the selection of the Pokemon's level by 1.
- Press the `UP`/`DOWN` buttons to paginate the selection of the Pokemon's level by 10.
- Press the `OK` button to select the Pokemon's level to trade.
- The `Select Moves` menu is used to pick the set the traded Pokemon's moves. They are pre-populated with the moveset that the Pokemon would know at level 1. Selecting a move slot will bring up an alphabetical index of moves. Additionally, `No Move` and `Default` can be quickliy selected. Note that any move after the first `No Move` is ignored.

<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-4.png" width="400" />
<img src="./docs/images/flipper-zero-flat-7.png" width="400" />
<br />
</p>

- The Flipper Zero should show the selection for the Pokemon's moves that you want to trade, this will happen 4 times with default bing no move.

<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-5.png" width="400" />
<img src="./docs/images/flipper-zero-flat-8.png" width="400" />
<br />
</p>

- Press the `LEFT`/`RIGHT` buttons to paginate the selection of the Pokemon's current move selection by 1.
- Press the `UP`/`DOWN` buttons to paginate the selection of the Pokemon's current move selection by 10.
- Press the `OK` button to select the Pokemon's current move selection to trade.
- The `Select Types` menu can change the traded Pokemon's types. The type(s) are pre-set to what the selected Pokemon normally is.
- Pokemon with a single type will have the same type set for both types.
- **Note:** Unlike other menus, changing either type immediately saves it. Pressing `Back` will keep any changes. This will be addressed in a later version. If you need to revert to the default types, a different Pokemon can be selected and the desired Pokemon re-selected.
- **Note:** When changing the type(s), the Pokemon's in-game stats will _NOT_ reflect the chosen type(s). Additionally, these may be overwritten back to default in-game if the Pokemon uses a move that affects types (e.g. `Transform`) or the Pokemon evolves.

<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-6.png" width="400" />
<img src="./docs/images/flipper-zero-flat-8-1.png" width="400" />
<br />
</p>

- The Flipper Zero should show the selection for the Pokemon's stats that you want to trade, and by default, it appears as random IV and zero EV.

- The Pokemon's stats can also be influenced. The current settings are:
- `Random IV, Zero EV` Mimics stats of a caught wild Pokemon.
- `Random IV, Max EV / Level` IV is randomized, but EV is set to the maximum a trained Pokemon could be for its current level.
- `Randon IV, Max EV` IV is randomized, EV is set to the abosolute max for a perfectly trained Pokemon.
- `Max IV, Zero EV` Mimics stats of a caught wild Pokemon, but with the maximum IV possible.
- `Max IV, Max EV / Level` IV is max, EV is set to the maximum a trained Pokemon could be for its current level.
- `Max IV, Max EV` Absolutely perfect and overly powerful Pokemon.

<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-7.png" width="400" />
<img src="./docs/images/flipper-zero-flat-5.png" width="400" />
<br />
</p>

- Press the `RIGHT`/`UP` buttons to paginate the selection of the Pokemon's stats selection by 1 positively.
- Press the `LEFT`/`DOWN` buttons to paginate the selection of the Pokemon's stats selection by 1 negatively.
- Press the `OK` button to select the Pokemon's current move selection to trade.
- The `OT ID#` and `OT Name` of the Pokemon can also be set. The `OT ID#` must be between `0` and `65535`. Setting the `OT ID#` and `OT Name` to the same as your current trainer's causes the game to believe it was a wild caught Pokemon and not one that was traded. This means high level Pokmon will still obey you without badges, but, will not get the experience boost of a traded Pokemon.

<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-8.png" width="400" />
<img src="./docs/images/flipper-zero-flat-6.png" width="400" /><br />
</p>

<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-6-1.png" width="400" /><br />
</p>

- The Flipper Zero will display the view to connect the Game Boy.
- Finally, select `Trade PKMN` to start the trade process.

<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-9.png" width="400" /><br />
<img src="./docs/images/flipper-zero-flat-6-2.png" width="400" /><br />
</p>

<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-9.png" width="400" /><br />
</p>

- On your Game Boy, you should connect the **Game Link Cable** to the Game Boy and in the game, go to the nearest **Pokemon Center**.

<p align='center'>
Expand Down Expand Up @@ -301,19 +321,10 @@ For each image, the color `#aaa` was transformed to `#fff` so that Flipper Zero
- Game Boy Color (GBC)
- Game Boy Advance (GBA)

## Implemented by
## Contributors
<a href="https://github.com/EstebanFuentealba/Flipper-Zero-Game-Boy-Pokemon-Trading/">EstebanFuentealba</a><br />
<a href="https://github.com/R4g3D/Flipper-Zero-Game-Boy-Pokemon-Trading/">R4g3D</a>

## TODO
- [x] Change the default traded Pokemon's naming to be no nickname
- [x] Add view to allow the traded Pokemon's level to be chosen between 3 and 100
- [x] Add view to allow the traded Pokemon's hidden stats to be chosen (IV and EV) from some options
- [x] Add view to allow the traded Pokemon's moveset to be chosen (all 4 moves) allowing no move as an option
- [ ] Debug traded Pokemon level issue where after a battle the Pokemon's level drops (doesn't affect all traded Pokemon)
- [x] Add images for the level selection screen, stats selection screen, and move selection screens as per the original README
- [ ] Optimise the level selection screen to be a number slider input instead of the current slideshow style selector
- [ ] Add a view to allow for a custom Pokemon nickname (11 chars, 10 chars max used, fill and terminate with TERM_)
<a href="https://github.com/R4g3D/Flipper-Zero-Game-Boy-Pokemon-Trading/">R4g3D</a><br />
<a href="https://github.com/kbembedded/Flipper-Zero-Game-Boy-Pokemon-Trading/">kbembedded</a>

## Links

Expand All @@ -325,3 +336,9 @@ For each image, the color `#aaa` was transformed to `#fff` so that Flipper Zero
- [Disassembly of Pokemon Yellow](https://github.com/pret/pokeyellow)
- [Arduino-Spoofing-Gameboy-Pokemon-Trades](https://github.com/EstebanFuentealba/Arduino-Spoofing-Gameboy-Pokemon-Trades)
- [🎮 Gameboy link cable breakout PCB](https://github.com/Palmr/gb-link-cable)

<p align='center'>
<br />
<br />
From Talcahuano 🇨🇱 with ❤
</p>
38 changes: 38 additions & 0 deletions README_catalog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 🐬 Flipper Zero - Pokemon Trading in Game Boy

## Introduction

This is a Pokemon exchange application from Flipper Zero to Game Boy (Generación I). Flipper Zero emulates a "Slave" Game Boy connected to a Game Link Cable to be able to exchange any Pokemon from the First Generation (Red, Blue, Yellow) to a real Game Boy.

It is a Proof of Concept (POC) for using views, GPIO, and FURI (Flipper Universal Registry Implementation).


## Connection: Flipper Zero GPIO - Game Boy

The pins should be connected as follows:

| Cable Game Link (Socket) | Flipper Zero GPIO |
| ------------------------ | ----------------- |
| 6 (GND) | 8 (GND) |
| 5 (CLK) | 6 (B2) |
| 3 (SI) | 7 (C3) |
| 2 (SO) | 5 (B3) |

## How does it work?

The method used to communicate 2 Game Boys is based on the SPI protocol, which is a very simple serial communication protocol in which a master device communicates with one or more slave devices. The protocol is bidirectional and synchronous, and uses three basic signals:

- A clock signal (CLK).
- An output signal (Serial Out or SO).
- An input signal (Serial In or SI).

In the Game Boy, games store data in an internal shift register that is used to send and receive information. The SPI protocol used by the Game Boy uses the clock signal to indicate when data is being transferred.

The Game Boy link protocol is synchronous and requires the slave device to respond at the same rate as the master device. The master device supplies an 8KHz clock (data transfer rate of 1KB/s). The time window for responding is only **~120μs**. However, the slave device has no restrictions and can respond when it receives data. The clock can vary and there is no lower limit.


## Tested In
- Game Boy Color (GBC)
- Game Boy Advance (GBA)


Loading

0 comments on commit 4522377

Please sign in to comment.