Skip to content

Commit

Permalink
First Commit 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanFuentealba committed Mar 24, 2023
1 parent 2fd49f0 commit 2f3a658
Show file tree
Hide file tree
Showing 219 changed files with 1,880 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
.vscode
219 changes: 219 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
# Flipper Zero - Pokemon Trading in Game Boy

<p align="center">
<a target="_blank" href="https://youtube.com/shorts/44rBn0jeGRk&feature=github.com">
<img align="center" alt="Flipper Zero - Pokemon Trading Game Boy" src="./docs/images/youtube.png" />
</a>
</p>

## IntroducciĂłn

Esta es una aplicaciĂłn de intercambio de Pokemon's desde de Flipper Zero a Game Boy [(GeneraciĂłn I)](https://bulbapedia.bulbagarden.net/wiki/Generation_I). Flipper Zero emula un Game Boy "Esclavo" conectado a **Cable Game Link** para poder intercambiar cualquier Pokemon de la Primera GeneraciĂłn (Red, Blue, Yellow) a un Game Boy Real.

Es una Prueba de concepto (POC) para utilizar vistas, GPIO y FURI (Flipper Universal Registry Implementation).

## Instrucciones de instalaciĂłn

Este proyecto está destinado a ser superpuesto encima de un repositorio de firmware existente, en mi caso la versión **Release 0.79.1**.

- Clona el [Repositorio del firmware de Flipper Zero](https://github.com/flipperdevices/flipperzero-firmware). Consulta este [tutorial](https://github.com/jamisonderek/flipper-zero-tutorials/tree/main/firmware/updating/README.md) para actualizar el firmware.
- Copia la [carpeta "pokemon"](..) en la carpeta `/applications_user/pokemon` del firmware que clonaste.
- Corre el comando `fbt launch_app` para correr en tu Flipper Zero.

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

- NOTA: Si sĂłlo quieres generar el archivo `fap` debes correr el siguiente comando.

```bash
./fbt fap_pokemon
```

y usa [**qFlipper**](https://flipperzero.one/update) para copiar el archivo **pokemon.fap** generado a la carpeta `SD Card/apps/Game Boy`.

<p align='center'>
<img src="./docs/images/qFlipper.png" width="400" /><br />
</p>

## Instrucciones de Uso

Estas instrucciones asumen que está comenzando en el escritorio de Flipper Zero. De lo contrario, presione el botón Atrás hasta que esté en el escritorio.

- Presione el botĂłn `OK` en el flipper para abrir el menĂş principal.
- Elija `Aplicaciones` en el menĂş.
- Elija `Game Boy` en el submenĂş.
- Elija `Pokemon Trading`
- El Flipper Zero debe mostrar la selecciĂłn de Pokemon que se desea intercambiar y por defecto parece bulbasaur.

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

- Pulse los botones `IZQUIERDA`/`DERECHA` para paginar de 1 en 1 la selecciĂłn de Pokemon.
- Pulse los botones `ARRIBA`/`ABAJO` para paginar de 10 en 10 la selecciĂłn de Pokemon.
- Pulse el botĂłn `OK` para seleccionar el Pokemon a Intercambiar.
<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-2.png" width="400" /><br />
</p>
- En el Flipper Zero se muestra la vista para conectar el Game Boy.
<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-3.png" width="400" /><br />
</p>
- En tu Game Boy debes conectar el **Cable Game Link** al Game Boy, en el juego dirigirte a un **Centro Pokémon** que tengas más cercano.
<p align='center'>
<br />
<img src="./docs/images/game_boy_pokemon_center.png" width="400" /><br />
</p>
- Habla con la chica que está en el mostrador de la derecha. La chica nos dirá que para poder jugar antes tendremos que salvar el juego, le contestaremos que _SI_ pulsando el botón _A_.
<p align='center'>
<br />
<img src="./docs/images/game_boy_save.png" width="400" /><br />
</p>
- El Flipper Zero nos mostrará que estámos conectados.
<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-4.png" width="400" /><br />
</p>
- En el Game Boy nos preguntará que opción queremos y Seleccionamos **CENT. CAMBIO**.
<p align='center'>
<br />
<img src="./docs/images/game_boy_save_trade.png" width="400" /><br />
</p>
- Entrarás a la sala de Intercambio donde debes presionar el botón A del Game Boy en el lado de tu mesa.
<p align='center'>
<br />
<img src="./docs/images/game_boy_trade_room_2.png" width="400" /><br />
</p>
- Flipper Zero quedará en una pantalla de espera con el Pokemon que seleccionaste.
<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-5.png" width="400" /><br />
</p>
- Se te mostrarán tus Pokemon y el Pokemon que seleccionaste en el Flipper Zero, en este Caso **Mew**. Debes seleccionar el pokemon que quieres intercambiar y presionar **TRATO**.
<p align='center'>
<br />
<img src="./docs/images/game_boy_trade_list_select_trade.png" width="400" /><br />
</p>
- Debes confirmar el intercambio seleccionado **TRATO**.
<p align='center'>
<br />
<img src="./docs/images/game_boy_trade_list_select_trade_confirm.png" width="400" /><br />
</p>
- Flipper Zero quedará en una pantalla de espera con el Pokemon que seleccionaste.
<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-6.png" width="400" /><br />
</p>
- Finalmente comenzará el intercambio de Pokemon desde **Flipper Zero** al **Game Boy**.
<p align='center'>
<br />
<img src="./docs/images/flipper-zero-flat-7.png" width="400" /><br />
</p>
- **NOTA**: Si al final del Intercambio se te bloquea el Flipper Zero debes Rebootear presionando la combinaciĂłn de teclas <img src="./docs/images/left.png" /> IZQUIERDA + <img src="./docs/images/back.png" /> ATRAS
<p align='center'>
<br />
<img src="./docs/images/reboot.png" width="400" /><br />
</p>

## ÂżCĂłmo trabaja?

El método utilizado para comunicar 2 Game Boy se basa en el protocolo SPI, que es un protocolo de comunicación serial muy simple en el que un dispositivo maestro se comunica con uno o más dispositivos esclavos. El protocolo es bidireccional y sincrónico, y utiliza tres señales básicas:

- Una señal de reloj (CLK).
- Una señal de salida (Serial Out o SO).
- Una señal de entrada (Serial In o SI).

En el Game Boy, los juegos almacenan los datos en un registro de cambio interno que se utiliza para enviar y recibir información. El protocolo SPI utilizado por el Game Boy utiliza la señal de reloj para indicar cuándo se transfieren los datos.

El protocolo de enlace de Game Boy es sĂ­ncrono y requiere que el dispositivo esclavo responda al mismo ritmo que el dispositivo maestro. El dispositivo maestro suministra un reloj de 8KHz (velocidad de transferencia de datos de 1KB/s). La ventana de tiempo para responder es de solo **~120ÎĽs**. Sin embargo, el dispositivo esclavo no tiene restricciones y puede responder cuando recibe los datos. El reloj puede variar y no hay un lĂ­mite inferior.

<p align='center'>
<br />
<img src="./docs/images/gb_spi.png" width="400" /><br />
</p>

_Una transferencia de ejemplo de GB SPI. AquĂ­, el maestro envĂ­a 0xD9 (217) y el esclavo envĂ­a 0x45 (69)._

<br />

Se puede conocer mas al respecto en el siguiente Video [**Analyzing the Different Versions of the Link Cable**](https://youtu.be/h1KKkCfzOws?t=151).

## Placa para Flipper Zero

Para la placa del Fipper Zero se utilizĂł un [PortData EXT Link](https://es.aliexpress.com/item/1005004116983895.html) y una [place de prototipo](https://es.aliexpress.com/item/32478242317.html) de 2x8.

<p align='center'>
<br />
<img src="./docs/images/EXT-Link.png" width="400" /><br />
</p>

_PortData EXT Link para Game Boy Color, Game Boy Pocket, GBC, GBP, GBL._

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

## ConexiĂłn: Flipper Zero GPIO - Game Boy

Se deben conectar los Pines de la siguiente manera

<p align='center'>
<br />
<img src="./docs/images/wgbl-0.png" width="400" /><br />
</p>

<picture>
<source media="(prefers-color-scheme: dark)" srcset="./docs/images/GPIO-GBPIN_light.png">
<source media="(prefers-color-scheme: light)" srcset="./docs/images/GPIO-GBPIN.png">
<img
alt="Connect Flipper Zero GPIO to Game Boy Pins"
src="./docs/images/GPIO-GBPIN.png">
</picture>

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

## GUI

Para generar la Interfaz gráfica se utilizó la herramienta [**FUI-Editor**](https://ilin.pt/stuff/fui-editor/).
Además se utilizaron los sprites originales del juego _Pokemon Yellow_ que se encuentran en el repositorio [**Disassembly of Pokemon Yellow**](https://github.com/pret/pokeyellow/tree/master/gfx/pokemon/front).

De cada imagen se transformĂł el color `#aaa` a `#fff` para que Flipper Zero la renderizara bien. Para eso se utilizĂł un **Batch** para [Photopea](https://www.photopea.com/), el editor de imagenes online.

## TODO

- [ ] Refactorizar el cĂłdigo
- [ ] Al salir de la app el botón `OK` deja de funcionar por lo que hay que reiniciarlo 🤔
- [ ] Setear a cada pokemon sus caracterĂ­sticas, ataques, niveles por defecto
- [ ] Mejorar animaciones

## Links

- [Flipper Zero firmware source code](https://github.com/flipperdevices/flipperzero-firmware)
- Adan Scotney's pokemon [trade protocol specification](http://www.adanscotney.com/2014/01/spoofing-pokemon-trades-with-stellaris.html) and implementation
- Derek Jamison - [Youtube Channel](https://www.youtube.com/@MrDerekJamison)
- Matt Penny - [GBPlay Blog](hhttps://blog.gbplay.io/)
- [Pokémon data structure (Generation I)](<https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_data_structure_(Generation_I)>)
- [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 />
Desde Talcahuano 🇨🇱 con ❤
</p>
11 changes: 11 additions & 0 deletions application.fam
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
App(
appid="pokemon",
name="Pokemon Trading",
apptype=FlipperAppType.EXTERNAL,
entry_point="pokemon_app",
requires=["gui"],
stack_size=2 * 1024,
fap_category="Game Boy",
fap_icon="pokemon_10px.png",
fap_icon_assets="assets"
)
Binary file added assets/Background.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 added assets/Background_128x11.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 added assets/Button_18x18.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 added assets/Connect_me_62x31.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 added assets/Connected_62x31.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 added assets/Space_100x18.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 added assets/Space_65x18.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 added assets/Space_80x18.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 added assets/Space_95x18.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 added assets/abra.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 added assets/aerodactyl.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 added assets/alakazam.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 added assets/arbok.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 added assets/arcanine.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 added assets/articuno.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 added assets/beedrill.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 added assets/bellsprout.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 added assets/blastoise.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 added assets/bulbasaur.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 added assets/butterfree.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 added assets/caterpie.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 added assets/chansey.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 added assets/charizard.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 added assets/charmander.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 added assets/charmeleon.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 added assets/clefable.png
Binary file added assets/clefairy.png
Binary file added assets/cloyster.png
Binary file added assets/cubone.png
Binary file added assets/dewgong.png
Binary file added assets/diglett.png
Binary file added assets/ditto.png
Binary file added assets/dodrio.png
Binary file added assets/doduo.png
Binary file added assets/dragonair.png
Binary file added assets/dragonite.png
Binary file added assets/dratini.png
Binary file added assets/drowzee.png
Binary file added assets/dugtrio.png
Binary file added assets/eevee.png
Binary file added assets/ekans.png
Binary file added assets/electabuzz.png
Binary file added assets/electrode.png
Binary file added assets/exeggcute.png
Binary file added assets/exeggutor.png
Binary file added assets/farfetchd.png
Binary file added assets/fearow.png
Binary file added assets/flareon.png
Binary file added assets/fossilaerodactyl.png
Binary file added assets/fossilkabutops.png
Binary file added assets/game_boy.png
Binary file added assets/gastly.png
Binary file added assets/gb_step_1.png
Binary file added assets/gb_step_2.png
Binary file added assets/gengar.png
Binary file added assets/geodude.png
Binary file added assets/gloom.png
Binary file added assets/golbat.png
Binary file added assets/goldeen.png
Binary file added assets/golduck.png
Binary file added assets/golem.png
Binary file added assets/graveler.png
Binary file added assets/grimer.png
Binary file added assets/growlithe.png
Binary file added assets/gyarados.png
Binary file added assets/haunter.png
Binary file added assets/hitmonchan.png
Binary file added assets/hitmonlee.png
Binary file added assets/horsea.png
Binary file added assets/hypno.png
Binary file added assets/ivysaur.png
Binary file added assets/jigglypuff.png
Binary file added assets/jolteon.png
Binary file added assets/jynx.png
Binary file added assets/kabuto.png
Binary file added assets/kabutops.png
Binary file added assets/kadabra.png
Binary file added assets/kakuna.png
Binary file added assets/kangaskhan.png
Binary file added assets/kingler.png
Binary file added assets/koffing.png
Binary file added assets/krabby.png
Binary file added assets/lapras.png
Binary file added assets/lickitung.png
Binary file added assets/machamp.png
Binary file added assets/machoke.png
Binary file added assets/machop.png
Binary file added assets/magikarp.png
Binary file added assets/magmar.png
Binary file added assets/magnemite.png
Binary file added assets/magneton.png
Binary file added assets/mankey.png
Binary file added assets/marowak.png
Binary file added assets/meowth.png
Binary file added assets/metapod.png
Binary file added assets/mew.png
Binary file added assets/mewtwo.png
Binary file added assets/moltres.png
Binary file added assets/mr.mime.png
Binary file added assets/muk.png
Binary file added assets/nidoking.png
Binary file added assets/nidoqueen.png
Binary file added assets/nidoranf.png
Binary file added assets/nidoranm.png
Binary file added assets/nidorina.png
Binary file added assets/nidorino.png
Binary file added assets/ninetales.png
Binary file added assets/oddish.png
Binary file added assets/omanyte.png
Binary file added assets/omastar.png
Binary file added assets/onix.png
Binary file added assets/paras.png
Binary file added assets/parasect.png
Binary file added assets/persian.png
Binary file added assets/pidgeot.png
Binary file added assets/pidgeotto.png
Binary file added assets/pidgey.png
Binary file added assets/pikachu.png
Binary file added assets/pinsir.png
Binary file added assets/poliwag.png
Binary file added assets/poliwhirl.png
Binary file added assets/poliwrath.png
Binary file added assets/ponyta.png
Binary file added assets/porygon.png
Binary file added assets/primeape.png
Binary file added assets/psyduck.png
Binary file added assets/raichu.png
Binary file added assets/rapidash.png
Binary file added assets/raticate.png
Binary file added assets/rattata.png
Binary file added assets/red.png
Binary file added assets/red_16x15.png
Binary file added assets/rhydon.png
Binary file added assets/rhyhorn.png
Binary file added assets/sandshrew.png
Binary file added assets/sandslash.png
Binary file added assets/scyther.png
Binary file added assets/seadra.png
Binary file added assets/seaking.png
Binary file added assets/seel.png
Binary file added assets/shellder.png
Binary file added assets/slowbro.png
Binary file added assets/slowpoke.png
Binary file added assets/snorlax.png
Binary file added assets/spearow.png
Binary file added assets/squirtle.png
Binary file added assets/starmie.png
Binary file added assets/staryu.png
Binary file added assets/tangela.png
Binary file added assets/tauros.png
Binary file added assets/tentacool.png
Binary file added assets/tentacruel.png
Binary file added assets/vaporeon.png
Binary file added assets/venomoth.png
Binary file added assets/venonat.png
Binary file added assets/venusaur.png
Binary file added assets/victreebel.png
Binary file added assets/vileplume.png
Binary file added assets/voltorb.png
Binary file added assets/vulpix.png
Binary file added assets/wartortle.png
Binary file added assets/weedle.png
Binary file added assets/weepinbell.png
Binary file added assets/weezing.png
Binary file added assets/wigglytuff.png
Binary file added assets/zapdos.png
Binary file added assets/zubat.png
Binary file added docs/images/1.png
Binary file added docs/images/2.png
Binary file added docs/images/3.png
Binary file added docs/images/4.png
Binary file added docs/images/5.png
Binary file added docs/images/6.png
Binary file added docs/images/7.png
Binary file added docs/images/EXT-Link.png
Binary file added docs/images/GPIO-GBPIN.png
Binary file added docs/images/GPIO-GBPIN_light.png
Binary file added docs/images/back.png
9 changes: 9 additions & 0 deletions docs/images/back.svg
Binary file added docs/images/dmg_link_port_pinout.png
Binary file added docs/images/flipper-zero-flat-1.png
Binary file added docs/images/flipper-zero-flat-2.png
Binary file added docs/images/flipper-zero-flat-3.png
Binary file added docs/images/flipper-zero-flat-4.png
Binary file added docs/images/flipper-zero-flat-5.png
Binary file added docs/images/flipper-zero-flat-6.png
Binary file added docs/images/flipper-zero-flat-7.png
Binary file added docs/images/flipper-zero-flat.png
Binary file added docs/images/flipper-zero-flat.psd
Diff not rendered.
Binary file added docs/images/flipper-zero-pcb.png
Binary file added docs/images/game_boy_pokemon_center.png
Binary file added docs/images/game_boy_save.png
Binary file added docs/images/game_boy_save_trade.png
Binary file added docs/images/game_boy_trade_list.png
Binary file added docs/images/game_boy_trade_list_select_trade.png
Binary file added docs/images/game_boy_trade_room.png
Binary file added docs/images/game_boy_trade_room_2.png
Binary file added docs/images/gb_spi.png
Binary file added docs/images/gblpof.gif
Binary file added docs/images/left.png
6 changes: 6 additions & 0 deletions docs/images/left.svg
Binary file added docs/images/pcb.png
Binary file added docs/images/qFlipper.png
Binary file added docs/images/reboot.png
Binary file added docs/images/wgbl-0.png
Loading

0 comments on commit 2f3a658

Please sign in to comment.