Skip to content

Commit a712da6

Browse files
committed
Set pokemon name to act like no nickname
1 parent 6f54ca2 commit a712da6

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,14 @@ For each image, the color `#aaa` was transformed to `#fff` so that Flipper Zero
264264
<a href="https://github.com/R4g3D/Flipper-Zero-Game-Boy-Pokemon-Trading/">R4g3D</a>
265265

266266
## TODO
267-
- [ ] Change the default traded Pokemon's naming to be no nickname (current nickname is the Pokemon's name)
267+
- [x] Change the default traded Pokemon's naming to be no nickname
268268
- [x] Add view to allow the traded Pokemon's level to be chosen between 3 and 100
269269
- [x] Add view to allow the traded Pokemon's hidden stats to be chosen (IV and EV) from some options
270270
- [x] Add view to allow the traded Pokemon's moveset to be chosen (all 4 moves) allowing no move as an option
271+
- [ ] Debug traded Pokemon level issue where after a battle the Pokemon's level drops (doesn't affect all traded Pokemon)
271272
- [ ] Add images for the level selection screen, stats selection screen, and move selection screens as per the original README
272-
- [ ] Optimise the level selection screen to be a number slider input instead of the current slideshow still selector
273-
- [ ] Add a view to allow for a custom Pokemon nickname
273+
- [ ] Optimise the level selection screen to be a number slider input instead of the current slideshow style selector
274+
- [ ] Add a view to allow for a custom Pokemon nickname (11 chars, 10 chars max used, fill and terminate with TERM_)
274275

275276
## Links
276277

pokemon_data.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ struct __attribute__((__packed__)) trade_data_block {
143143
};
144144

145145
struct trade_data_block DATA_BLOCK2 =
146-
{.trainer_name = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00, 0x00},
146+
{.trainer_name = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_},
147147
.party_cnt = 1,
148148
.party_members = {0x15, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
149149
.party =
@@ -281,23 +281,22 @@ struct trade_data_block DATA_BLOCK2 =
281281
.spd = 0x9800,
282282
.special = 0x9900},
283283
},
284-
/* NOTE: I think this shouldn't exceed 7 chars */
285284
.ot_name =
286285
{
287-
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
288-
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
289-
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
290-
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
291-
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
292-
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
286+
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
287+
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
288+
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
289+
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
290+
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
291+
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
293292
},
294293
.nickname = {
295-
{.str = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
296-
{.str = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
297-
{.str = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
298-
{.str = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
299-
{.str = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
300-
{.str = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
294+
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
295+
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
296+
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
297+
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
298+
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
299+
{.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, TERM_, TERM_, TERM_}},
301300
}};
302301

303302
unsigned char INPUT_BLOCK[405];

views/trade.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -391,21 +391,15 @@ void trade_enter_callback(void* context) {
391391

392392
unsigned char nickname[11];
393393
for (size_t i = 0; i < 11; ++i) {
394-
nickname[i] = 0x00;
394+
nickname[i] = 0x50;
395395
}
396396
for (size_t i = 0; i < strlen(pokemon_table[trade->app->current_pokemon].name); ++i) {
397397
nickname[i] = convertCharToTagHex(pokemon_table[trade->app->current_pokemon].name[i]);
398398
}
399-
for (size_t i = 0; i < 11; ++i) {
400-
if(nickname[i] == 0x00) {
401-
nickname[i] = 0x50;
402-
}
403-
break;
404-
}
405399

406400
memcpy(DATA_BLOCK2.nickname[0].str, nickname, sizeof(nickname));
407401

408-
FURI_LOG_D(TAG, "[Trade] Pokemon Name: %s", nickname);
402+
FURI_LOG_D(TAG, "[Trade] Pokemon Name: %s", pokemon_table[trade->app->current_pokemon].name);
409403

410404
// Set the Pokemon hex code
411405

@@ -417,15 +411,15 @@ void trade_enter_callback(void* context) {
417411

418412
FURI_LOG_D(TAG, "[Trade] Current Level: %d", trade->app->current_level);
419413

420-
int level = trade->app->current_level;
414+
uint8_t level = trade->app->current_level;
421415
DATA_BLOCK2.party[0].level = level & 0xFF;
422416
DATA_BLOCK2.party[0].level_again = level & 0xFF;
423417

424418
FURI_LOG_D(TAG, "[Trade] Level Hex Code: %x", DATA_BLOCK2.party[0].level);
425419

426420
// Set the Pokemon experience
427421

428-
int exp = 0;
422+
int32_t exp = 0;
429423
if(pokemon_table[trade->app->current_pokemon].xp_group == 0) {
430424
exp = 1.25 * level * level * level;
431425
} else if(pokemon_table[trade->app->current_pokemon].xp_group == 1) {
@@ -435,6 +429,7 @@ void trade_enter_callback(void* context) {
435429
} else if(pokemon_table[trade->app->current_pokemon].xp_group == 3) {
436430
exp = 0.8 * level * level * level;
437431
}
432+
438433
DATA_BLOCK2.party[0].exp[0] = (exp >> 16) & 0xFF;
439434
DATA_BLOCK2.party[0].exp[1] = (exp >> 8) & 0xFF;
440435
DATA_BLOCK2.party[0].exp[2] = exp & 0xFF;
@@ -509,7 +504,11 @@ void trade_enter_callback(void* context) {
509504
// Set the Pokemon types
510505

511506
DATA_BLOCK2.party[0].type[0] = pokemon_table[trade->app->current_pokemon].type1;
512-
DATA_BLOCK2.party[0].type[1] = pokemon_table[trade->app->current_pokemon].type2;
507+
if(pokemon_table[trade->app->current_pokemon].type2 == 0xFF) {
508+
DATA_BLOCK2.party[0].type[1] = pokemon_table[trade->app->current_pokemon].type1;
509+
} else {
510+
DATA_BLOCK2.party[0].type[1] = pokemon_table[trade->app->current_pokemon].type2;
511+
}
513512

514513
FURI_LOG_D(TAG, "[Trade] Type 1: %x", DATA_BLOCK2.party[0].type[0]);
515514
FURI_LOG_D(TAG, "[Trade] Type 2: %x", DATA_BLOCK2.party[0].type[1]);

0 commit comments

Comments
 (0)