mirror of
https://github.com/GrenderG/mewdistro.git
synced 2026-04-26 02:02:33 -05:00
Formatting.
This commit is contained in:
parent
53b47da2aa
commit
73c3a0109c
349
gen1.h
349
gen1.h
|
|
@ -4,205 +4,210 @@
|
|||
#include <gb/gb.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define PKMN_BLANK 0x00
|
||||
// Protocol opcodes.
|
||||
|
||||
#define ITEM_1_HIGHLIGHTED 0xD0
|
||||
#define ITEM_2_HIGHLIGHTED 0xD1
|
||||
#define ITEM_3_HIGHLIGHTED 0xD2
|
||||
#define ITEM_1_SELECTED 0xD4
|
||||
#define ITEM_2_SELECTED 0xD5
|
||||
#define ITEM_3_SELECTED 0xD6
|
||||
#define PKMN_BLANK 0x00
|
||||
|
||||
#define PKMN_MASTER 0x01
|
||||
#define PKMN_SLAVE 0x02
|
||||
#define PKMN_CONNECTED 0x60
|
||||
#define PKMN_CONNECTED_TIME_CAPSULE 0x61
|
||||
// #define PKMN_CONNECTED 0x03
|
||||
#define PKMN_WAIT 0x7F
|
||||
#define ITEM_1_HIGHLIGHTED 0xD0
|
||||
#define ITEM_2_HIGHLIGHTED 0xD1
|
||||
#define ITEM_3_HIGHLIGHTED 0xD2
|
||||
#define ITEM_1_SELECTED 0xD4
|
||||
#define ITEM_2_SELECTED 0xD5
|
||||
#define ITEM_3_SELECTED 0xD6
|
||||
|
||||
#define PKMN_ACTION 0x60
|
||||
#define PKMN_MASTER 0x01
|
||||
#define PKMN_SLAVE 0x02
|
||||
#define PKMN_CONNECTED 0x60
|
||||
#define PKMN_CONNECTED_TIME_CAPSULE 0x61
|
||||
// #define PKMN_CONNECTED 0x03
|
||||
#define PKMN_WAIT 0x7F
|
||||
|
||||
#define PKMN_TRADE_CENTRE ITEM_1_SELECTED
|
||||
#define PKMN_COLOSSEUM ITEM_2_SELECTED
|
||||
#define PKMN_BREAK_LINK ITEM_3_SELECTED
|
||||
#define PKMN_ACTION 0x60
|
||||
|
||||
#define PKMN_TRADE_CENTRE ITEM_1_SELECTED
|
||||
#define PKMN_COLOSSEUM ITEM_2_SELECTED
|
||||
#define PKMN_BREAK_LINK ITEM_3_SELECTED
|
||||
#define PKMN_TIME_CAPSULE_SELECT 0xD1
|
||||
|
||||
#define TRADE_CENTRE_WAIT 0xFD
|
||||
#define TRADE_CENTRE_WAIT 0xFD
|
||||
|
||||
#define pokechar_STOP_BYTE 0x50
|
||||
|
||||
// Text definitions.
|
||||
|
||||
#define pokechar_STOP_BYTE 0x50
|
||||
// Ends a string
|
||||
#define pokechar_NULL_BYTE 0x00
|
||||
#define pokechar_NULL_BYTE 0x00
|
||||
// Nothing, comes after the stop byte to fill in the rest
|
||||
|
||||
// ENG Characters
|
||||
#define pokechar_SPACE 0x7F
|
||||
#define pokechar_A 0x80
|
||||
#define pokechar_B 0x81
|
||||
#define pokechar_C 0x82
|
||||
#define pokechar_D 0x83
|
||||
#define pokechar_E 0x84
|
||||
#define pokechar_F 0x85
|
||||
#define pokechar_G 0x86
|
||||
#define pokechar_H 0x87
|
||||
#define pokechar_I 0x88
|
||||
#define pokechar_J 0x89
|
||||
#define pokechar_K 0x8A
|
||||
#define pokechar_L 0x8B
|
||||
#define pokechar_M 0x8C
|
||||
#define pokechar_N 0x8D
|
||||
#define pokechar_O 0x8E
|
||||
#define pokechar_P 0x8F
|
||||
#define pokechar_Q 0x90
|
||||
#define pokechar_R 0x91
|
||||
#define pokechar_S 0x92
|
||||
#define pokechar_T 0x93
|
||||
#define pokechar_U 0x94
|
||||
#define pokechar_V 0x95
|
||||
#define pokechar_W 0x96
|
||||
#define pokechar_X 0x97
|
||||
#define pokechar_Y 0x98
|
||||
#define pokechar_Z 0x99
|
||||
#define pokechar_OPEN_PARENTHESIS 0x9A
|
||||
#define pokechar_CLOSE_PARENTHESIS 0x9B
|
||||
#define pokechar_COLON 0x9C
|
||||
#define pokechar_SEMICOLON 0x9D
|
||||
#define pokechar_OPEN_BRACKET 0x9E
|
||||
#define pokechar_CLOSE_BRACKET 0x9F
|
||||
#define pokechar_a 0xA0
|
||||
#define pokechar_b 0xA1
|
||||
#define pokechar_c 0xA2
|
||||
#define pokechar_d 0xA3
|
||||
#define pokechar_e 0xA4
|
||||
#define pokechar_f 0xA5
|
||||
#define pokechar_g 0xA6
|
||||
#define pokechar_h 0xA7
|
||||
#define pokechar_i 0xA8
|
||||
#define pokechar_j 0xA9
|
||||
#define pokechar_k 0xAa
|
||||
#define pokechar_l 0xAb
|
||||
#define pokechar_m 0xAc
|
||||
#define pokechar_n 0xAd
|
||||
#define pokechar_o 0xAe
|
||||
#define pokechar_p 0xAf
|
||||
#define pokechar_q 0xB0
|
||||
#define pokechar_r 0xB1
|
||||
#define pokechar_s 0xB2
|
||||
#define pokechar_t 0xB3
|
||||
#define pokechar_u 0xB4
|
||||
#define pokechar_v 0xB5
|
||||
#define pokechar_w 0xB6
|
||||
#define pokechar_x 0xB7
|
||||
#define pokechar_y 0xB8
|
||||
#define pokechar_z 0xB9
|
||||
#define pokechar_e_accent 0xBA
|
||||
#define pokechar_apostrophe_d 0xBB
|
||||
#define pokechar_apostrophe_l 0xBC
|
||||
#define pokechar_apostrophe_s 0xBD
|
||||
#define pokechar_apostrophe_t 0xBE
|
||||
#define pokechar_apostrophe_v 0xBF
|
||||
#define pokechar_apostrophe 0xE0
|
||||
#define pokechar_PK_character 0xE1
|
||||
#define pokechar_MN_character 0xE2
|
||||
#define pokechar_hyphen 0xE3
|
||||
#define pokechar_apostrophe_r 0xE4
|
||||
#define pokechar_apostrophe_m 0xE5
|
||||
#define pokechar_question_mark 0xE6
|
||||
#define pokechar_exclamation_mark 0xE7
|
||||
#define pokechar_SPACE 0x7F
|
||||
#define pokechar_A 0x80
|
||||
#define pokechar_B 0x81
|
||||
#define pokechar_C 0x82
|
||||
#define pokechar_D 0x83
|
||||
#define pokechar_E 0x84
|
||||
#define pokechar_F 0x85
|
||||
#define pokechar_G 0x86
|
||||
#define pokechar_H 0x87
|
||||
#define pokechar_I 0x88
|
||||
#define pokechar_J 0x89
|
||||
#define pokechar_K 0x8A
|
||||
#define pokechar_L 0x8B
|
||||
#define pokechar_M 0x8C
|
||||
#define pokechar_N 0x8D
|
||||
#define pokechar_O 0x8E
|
||||
#define pokechar_P 0x8F
|
||||
#define pokechar_Q 0x90
|
||||
#define pokechar_R 0x91
|
||||
#define pokechar_S 0x92
|
||||
#define pokechar_T 0x93
|
||||
#define pokechar_U 0x94
|
||||
#define pokechar_V 0x95
|
||||
#define pokechar_W 0x96
|
||||
#define pokechar_X 0x97
|
||||
#define pokechar_Y 0x98
|
||||
#define pokechar_Z 0x99
|
||||
#define pokechar_OPEN_PARENTHESIS 0x9A
|
||||
#define pokechar_CLOSE_PARENTHESIS 0x9B
|
||||
#define pokechar_COLON 0x9C
|
||||
#define pokechar_SEMICOLON 0x9D
|
||||
#define pokechar_OPEN_BRACKET 0x9E
|
||||
#define pokechar_CLOSE_BRACKET 0x9F
|
||||
#define pokechar_a 0xA0
|
||||
#define pokechar_b 0xA1
|
||||
#define pokechar_c 0xA2
|
||||
#define pokechar_d 0xA3
|
||||
#define pokechar_e 0xA4
|
||||
#define pokechar_f 0xA5
|
||||
#define pokechar_g 0xA6
|
||||
#define pokechar_h 0xA7
|
||||
#define pokechar_i 0xA8
|
||||
#define pokechar_j 0xA9
|
||||
#define pokechar_k 0xAa
|
||||
#define pokechar_l 0xAb
|
||||
#define pokechar_m 0xAc
|
||||
#define pokechar_n 0xAd
|
||||
#define pokechar_o 0xAe
|
||||
#define pokechar_p 0xAf
|
||||
#define pokechar_q 0xB0
|
||||
#define pokechar_r 0xB1
|
||||
#define pokechar_s 0xB2
|
||||
#define pokechar_t 0xB3
|
||||
#define pokechar_u 0xB4
|
||||
#define pokechar_v 0xB5
|
||||
#define pokechar_w 0xB6
|
||||
#define pokechar_x 0xB7
|
||||
#define pokechar_y 0xB8
|
||||
#define pokechar_z 0xB9
|
||||
#define pokechar_e_accent 0xBA
|
||||
#define pokechar_apostrophe_d 0xBB
|
||||
#define pokechar_apostrophe_l 0xBC
|
||||
#define pokechar_apostrophe_s 0xBD
|
||||
#define pokechar_apostrophe_t 0xBE
|
||||
#define pokechar_apostrophe_v 0xBF
|
||||
#define pokechar_apostrophe 0xE0
|
||||
#define pokechar_PK_character 0xE1
|
||||
#define pokechar_MN_character 0xE2
|
||||
#define pokechar_hyphen 0xE3
|
||||
#define pokechar_apostrophe_r 0xE4
|
||||
#define pokechar_apostrophe_m 0xE5
|
||||
#define pokechar_question_mark 0xE6
|
||||
#define pokechar_exclamation_mark 0xE7
|
||||
|
||||
// NOTE: `period` is never used in names. Instead use `decimal_point`
|
||||
// . (used as punctuation)
|
||||
#define pokechar_period 0xE8
|
||||
#define pokechar_period 0xE8
|
||||
|
||||
#define pokechar_hollow_play 0xEC
|
||||
#define pokechar_hollow_play 0xEC
|
||||
// ▷
|
||||
#define pokechar_solid_play 0xED
|
||||
#define pokechar_solid_play 0xED
|
||||
// ▶
|
||||
#define pokechar_solid_down 0xEE
|
||||
#define pokechar_solid_down 0xEE
|
||||
// ▼
|
||||
#define pokechar_male_symbol 0xEF
|
||||
#define pokechar_male_symbol 0xEF
|
||||
// ♂
|
||||
#define pokechar_pokemon_dollar 0xF0
|
||||
#define pokechar_multiply 0xF1
|
||||
#define pokechar_pokemon_dollar 0xF0
|
||||
#define pokechar_multiply 0xF1
|
||||
// ×
|
||||
#define pokechar_decimal_point 0xF2
|
||||
#define pokechar_decimal_point 0xF2
|
||||
// . (used as a decimal point)
|
||||
#define pokechar_slash_forward 0xF3
|
||||
#define pokechar_slash_forward 0xF3
|
||||
// /
|
||||
#define pokechar_comma 0xF4
|
||||
#define pokechar_comma 0xF4
|
||||
// ,
|
||||
#define pokechar_female_symbol 0xF5
|
||||
#define pokechar_female_symbol 0xF5
|
||||
// ♀
|
||||
#define pokechar_zero 0xF6
|
||||
#define pokechar_one 0xF7
|
||||
#define pokechar_two 0xF8
|
||||
#define pokechar_three 0xF9
|
||||
#define pokechar_four 0xFA
|
||||
#define pokechar_five 0xFB
|
||||
#define pokechar_six 0xFC
|
||||
#define pokechar_seven 0xFD
|
||||
#define pokechar_eight 0xFE
|
||||
#define pokechar_nine 0xFF
|
||||
#define pokechar_zero 0xF6
|
||||
#define pokechar_one 0xF7
|
||||
#define pokechar_two 0xF8
|
||||
#define pokechar_three 0xF9
|
||||
#define pokechar_four 0xFA
|
||||
#define pokechar_five 0xFB
|
||||
#define pokechar_six 0xFC
|
||||
#define pokechar_seven 0xFD
|
||||
#define pokechar_eight 0xFE
|
||||
#define pokechar_nine 0xFF
|
||||
// Characters that weren't removed from JPN when translating to ENG
|
||||
// Some seem bolded, some are symbols, others are katakana or hiragana letters
|
||||
#define pokechar_JPN_A 0x60
|
||||
#define pokechar_JPN_B 0x61
|
||||
#define pokechar_JPN_C 0x62
|
||||
#define pokechar_JPN_D 0x63
|
||||
#define pokechar_JPN_E 0x64
|
||||
#define pokechar_JPN_F 0x65
|
||||
#define pokechar_JPN_G 0x66
|
||||
#define pokechar_JPN_H 0x67
|
||||
#define pokechar_JPN_I 0x68
|
||||
#define pokechar_JPN_V 0x69
|
||||
#define pokechar_JPN_S 0x6A
|
||||
#define pokechar_JPN_L 0x6B
|
||||
#define pokechar_JPN_M 0x6C
|
||||
#define pokechar_JPN_colon 0x6D
|
||||
#define pokechar_hiragana_i 0x6E
|
||||
#define pokechar_JPN_A 0x60
|
||||
#define pokechar_JPN_B 0x61
|
||||
#define pokechar_JPN_C 0x62
|
||||
#define pokechar_JPN_D 0x63
|
||||
#define pokechar_JPN_E 0x64
|
||||
#define pokechar_JPN_F 0x65
|
||||
#define pokechar_JPN_G 0x66
|
||||
#define pokechar_JPN_H 0x67
|
||||
#define pokechar_JPN_I 0x68
|
||||
#define pokechar_JPN_V 0x69
|
||||
#define pokechar_JPN_S 0x6A
|
||||
#define pokechar_JPN_L 0x6B
|
||||
#define pokechar_JPN_M 0x6C
|
||||
#define pokechar_JPN_colon 0x6D
|
||||
#define pokechar_hiragana_i 0x6E
|
||||
// ぃ
|
||||
#define pokechar_hiragana_u 0x6F
|
||||
#define pokechar_hiragana_u 0x6F
|
||||
// ぅ
|
||||
#define pokechar_open_single_quote 0x70
|
||||
#define pokechar_open_single_quote 0x70
|
||||
// ‘
|
||||
#define pokechar_close_single_quote 0x71
|
||||
#define pokechar_close_single_quote 0x71
|
||||
// ’
|
||||
#define pokechar_open_double_quote 0x72
|
||||
#define pokechar_open_double_quote 0x72
|
||||
// “
|
||||
#define pokechar_close_double_quote 0x73
|
||||
#define pokechar_close_double_quote 0x73
|
||||
// ”
|
||||
#define pokechar_dot 0x74
|
||||
#define pokechar_dot 0x74
|
||||
// ・
|
||||
#define pokechar_ellipsis 0x75
|
||||
#define pokechar_ellipsis 0x75
|
||||
// ⋯
|
||||
#define pokechar_hiragana_a 0x76
|
||||
#define pokechar_hiragana_a 0x76
|
||||
// ぁ
|
||||
#define pokechar_hiragana_e 0x77
|
||||
#define pokechar_hiragana_e 0x77
|
||||
// ぇ
|
||||
#define pokechar_hiragana_o 0x78
|
||||
#define pokechar_hiragana_o 0x78
|
||||
// ぉ
|
||||
#define pokechar_katakana_a 0xE9
|
||||
#define pokechar_katakana_a 0xE9
|
||||
// ァ
|
||||
#define pokechar_katakana_u 0xEA
|
||||
#define pokechar_katakana_u 0xEA
|
||||
// ゥ
|
||||
#define pokechar_katakana_e 0xEB
|
||||
#define pokechar_katakana_e 0xEB
|
||||
// ェ
|
||||
|
||||
enum connection_state_t {
|
||||
TRADE_CENTRE,
|
||||
NOT_CONNECTED,
|
||||
CONNECTED,
|
||||
COLOSSEUM,
|
||||
TRADE_CENTRE,
|
||||
NOT_CONNECTED,
|
||||
CONNECTED,
|
||||
COLOSSEUM,
|
||||
};
|
||||
|
||||
enum trade_state_t {
|
||||
INIT = 0x00,
|
||||
READY = 0x01,
|
||||
DETECTED = 0x02,
|
||||
DATA_TX = 0x03,
|
||||
DATA_TX_WAIT = 0x04,
|
||||
DATA_TX_WAIT_HOLD = 0x05,
|
||||
DATA_TX_START = 0x06,
|
||||
DATA_TX_RANDOM = 0x07,
|
||||
INIT = 0x00,
|
||||
READY = 0x01,
|
||||
DETECTED = 0x02,
|
||||
DATA_TX = 0x03,
|
||||
DATA_TX_WAIT = 0x04,
|
||||
DATA_TX_WAIT_HOLD = 0x05,
|
||||
DATA_TX_START = 0x06,
|
||||
DATA_TX_RANDOM = 0x07,
|
||||
DATA_TX_PATCH = 0x08,
|
||||
TRADE_WAIT = 0x09,
|
||||
TRADE_DONE = 0x0A,
|
||||
|
|
@ -565,7 +570,6 @@ typedef struct SelectedPokemon {
|
|||
enum gen_one_dex_t pokemon[6];
|
||||
} SelectedPokemon;
|
||||
|
||||
|
||||
// Luckily it follows the save file structure closely enough
|
||||
// https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_data_structure_(Generation_I)
|
||||
typedef struct PartyMember {
|
||||
|
|
@ -575,33 +579,42 @@ typedef struct PartyMember {
|
|||
uint8_t level;
|
||||
enum status_condition_t status;
|
||||
enum poke_type_t type1;
|
||||
enum poke_type_t type2; // If only one type, copy the first
|
||||
uint8_t catch_rate_or_held_item; // R/G/B/Y (catch rate), G/S/C (held item), and Stadium (held item) use this byte differently
|
||||
enum poke_type_t type2; // If only one type, copy the first
|
||||
uint8_t catch_rate_or_held_item; // R/G/B/Y (catch rate), G/S/C (held
|
||||
// item), and Stadium (held item) use this
|
||||
// byte differently
|
||||
enum poke_move_t move1;
|
||||
enum poke_move_t move2;
|
||||
enum poke_move_t move3;
|
||||
enum poke_move_t move4;
|
||||
uint16_t original_trainer_id; // In decimal, these are the funny numbers
|
||||
uint16_t original_trainer_id; // In decimal, these are the funny numbers
|
||||
|
||||
// - Experience is complicated. You must look up the Pokemon you are trying to trade
|
||||
// in the following table and apply the experience points that match the level.
|
||||
// EXP LVL Table for gen 1: https://pwo-wiki.info/index.php/Generation_I_Experience_Charts
|
||||
// That source was the best I could find for Gen 1. If you find another, submit a PR or open an issue and I'll fix it
|
||||
// - Experience is a 24bit number, we will be dropping the MSB to acheive that
|
||||
// - Experience is complicated. You must look up the Pokemon you are
|
||||
// trying to trade
|
||||
// in the following table and apply the experience points that match
|
||||
// the level. EXP LVL Table for gen 1:
|
||||
// https://pwo-wiki.info/index.php/Generation_I_Experience_Charts That
|
||||
// source was the best I could find for Gen 1. If you find another,
|
||||
// submit a PR or open an issue and I'll fix it
|
||||
// - Experience is a 24bit number, we will be dropping the MSB to acheive
|
||||
// that
|
||||
uint32_t experience;
|
||||
|
||||
// Effort Values
|
||||
// These are very specific to the Pokemon and who they battled in the past or what vitamins they were fed
|
||||
// Luckily, these get recalculated when you level them up, or when you put them in a box and then put them back in your party
|
||||
// For this example, I will take the max value and scale it to the level (65535 * 0.40) = 26214
|
||||
// These are very specific to the Pokemon and who they battled in the past
|
||||
// or what vitamins they were fed Luckily, these get recalculated when you
|
||||
// level them up, or when you put them in a box and then put them back in
|
||||
// your party For this example, I will take the max value and scale it to
|
||||
// the level (65535 * 0.40) = 26214
|
||||
uint16_t HP_ev;
|
||||
uint16_t attack_ev;
|
||||
uint16_t defense_ev;
|
||||
uint16_t speed_ev;
|
||||
uint16_t special_ev;
|
||||
|
||||
// IVs are a 4 bit number, so the max value is 15 (0-15 = 0b0000-0b1111 = 0x0-0xF)
|
||||
// These have been broken out for legibility, but will be condensed to only 2 bytes
|
||||
// IVs are a 4 bit number, so the max value is 15 (0-15 = 0b0000-0b1111 =
|
||||
// 0x0-0xF) These have been broken out for legibility, but will be condensed
|
||||
// to only 2 bytes
|
||||
uint8_t attack_iv;
|
||||
uint8_t defense_iv;
|
||||
uint8_t speed_iv;
|
||||
|
|
|
|||
289
mewdistro.c
289
mewdistro.c
|
|
@ -1,10 +1,10 @@
|
|||
#include <gb/gb.h>
|
||||
#include <gb/hardware.h>
|
||||
#include <gbdk/console.h>
|
||||
#include <rand.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <rand.h>
|
||||
#include <gbdk/console.h>
|
||||
|
||||
#include "gen1.h"
|
||||
|
||||
|
|
@ -12,68 +12,41 @@
|
|||
#define POKE_SIZE 44
|
||||
#define NAME_LEN 11
|
||||
#define SELP_LEN 8
|
||||
#define POKE_LEN POKE_SIZE * PARTY_SIZE
|
||||
#define ORIG_LEN NAME_LEN * PARTY_SIZE
|
||||
#define NICK_LEN NAME_LEN * PARTY_SIZE
|
||||
#define POKE_LEN POKE_SIZE *PARTY_SIZE
|
||||
#define ORIG_LEN NAME_LEN *PARTY_SIZE
|
||||
#define NICK_LEN NAME_LEN *PARTY_SIZE
|
||||
#define FULL_LEN NAME_LEN + SELP_LEN + (POKE_SIZE * PARTY_SIZE) + (NAME_LEN * PARTY_SIZE) + (NAME_LEN * PARTY_SIZE)
|
||||
|
||||
#define SER_REG_DIR (*(uint8_t *)0xFF01)
|
||||
#define SER_OPT_REG_DIR (*(uint8_t *)0xFF02)
|
||||
|
||||
|
||||
const unsigned char mew_tiles[] =
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x01,0x03,0x06,0x01,0x08,0x09,0x09,
|
||||
0x02,0x12,0x1A,0x12,0x08,0x11,0x09,0x09,
|
||||
0x00,0x09,0x07,0x04,0x03,0x04,0x03,0x02,
|
||||
0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x01,0x03,0x03,0x07,0x00,0x00,
|
||||
0x30,0x78,0x66,0x47,0x50,0x60,0x28,0x30,
|
||||
0x20,0x30,0x00,0x20,0x25,0x46,0x46,0x49,
|
||||
0x47,0x4B,0x22,0x4A,0x23,0x23,0x21,0x21,
|
||||
0xD3,0xE0,0xF4,0x18,0xF8,0x7E,0x02,0x83,
|
||||
0x00,0x00,0x01,0x01,0x07,0x0F,0x03,0x11,
|
||||
0x13,0x11,0x87,0x8E,0xC7,0x46,0x2F,0xFE,
|
||||
0x96,0xFF,0x77,0x7F,0x13,0x1F,0x0B,0x0F,
|
||||
0x7F,0xFF,0xE7,0xFF,0xFF,0xFF,0x00,0x00,
|
||||
0xFC,0xFE,0x83,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x02,0x01,0x85,0x02,
|
||||
0x43,0x87,0x85,0x85,0x87,0x87,0x7A,0x86,
|
||||
0xFE,0x00,0x01,0x00,0x00,0x01,0x03,0x03,
|
||||
0xFC,0xFF,0x87,0xF8,0x08,0xF0,0x30,0xC0,
|
||||
0xC0,0x00,0x00,0x00,0x01,0x00,0x00,0x02,
|
||||
0x84,0x04,0x44,0x84,0xB8,0xC4,0xF3,0xFA,
|
||||
0xC1,0xE1,0x81,0x81,0x00,0x00,0x00,0x00,
|
||||
0x00,0x01,0x02,0x06,0x00,0x08,0x10,0x10,
|
||||
0x00,0x10,0x06,0x0E,0x00,0x01,0x00,0x00,
|
||||
0x1C,0x1C,0x64,0xE4,0xCC,0x44,0x14,0x0C,
|
||||
0x10,0x0C,0x18,0x08,0x88,0x84,0x84,0x44,
|
||||
0x8E,0x47,0x0F,0x44,0x09,0x07,0x18,0x08,
|
||||
0x30,0x10,0x40,0x60,0x80,0x80,0x00,0x00,
|
||||
0x80,0x80,0xC0,0x60,0xF8,0x18,0x7C,0x84,
|
||||
0xBE,0x42,0xFC,0x64,0xD8,0x58,0xC0,0x20,
|
||||
0x60,0x20,0x60,0x20,0xE0,0x20,0xD0,0x70,
|
||||
0x7C,0x8C,0x63,0x83,0xC9,0xC0,0x1F,0x3F,
|
||||
0x80,0xC0,0x20,0x30,0x08,0x08,0x08,0x04,
|
||||
0x0C,0x04,0x1C,0x02,0xFE,0xE2,0x0E,0x12,
|
||||
0x06,0x0A,0x0A,0x0A,0x0A,0x0A,0x08,0x0A,
|
||||
0x04,0x12,0x14,0x14,0x28,0x24,0x98,0xC8,
|
||||
0xF0,0x10,0xC0,0x60,0x00,0x80,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x80,0xC0,0x40,0x00,0x80,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
// Mew image.
|
||||
const unsigned char mew_tiles[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x01, 0x08, 0x09, 0x09, 0x02, 0x12, 0x1A,
|
||||
0x12, 0x08, 0x11, 0x09, 0x09, 0x00, 0x09, 0x07, 0x04, 0x03, 0x04, 0x03, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x07, 0x00, 0x00, 0x30, 0x78, 0x66, 0x47, 0x50, 0x60, 0x28, 0x30, 0x20,
|
||||
0x30, 0x00, 0x20, 0x25, 0x46, 0x46, 0x49, 0x47, 0x4B, 0x22, 0x4A, 0x23, 0x23, 0x21, 0x21, 0xD3, 0xE0, 0xF4, 0x18,
|
||||
0xF8, 0x7E, 0x02, 0x83, 0x00, 0x00, 0x01, 0x01, 0x07, 0x0F, 0x03, 0x11, 0x13, 0x11, 0x87, 0x8E, 0xC7, 0x46, 0x2F,
|
||||
0xFE, 0x96, 0xFF, 0x77, 0x7F, 0x13, 0x1F, 0x0B, 0x0F, 0x7F, 0xFF, 0xE7, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFC, 0xFE,
|
||||
0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x85, 0x02, 0x43, 0x87, 0x85, 0x85, 0x87,
|
||||
0x87, 0x7A, 0x86, 0xFE, 0x00, 0x01, 0x00, 0x00, 0x01, 0x03, 0x03, 0xFC, 0xFF, 0x87, 0xF8, 0x08, 0xF0, 0x30, 0xC0,
|
||||
0xC0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x84, 0x04, 0x44, 0x84, 0xB8, 0xC4, 0xF3, 0xFA, 0xC1, 0xE1, 0x81,
|
||||
0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x06, 0x00, 0x08, 0x10, 0x10, 0x00, 0x10, 0x06, 0x0E, 0x00, 0x01,
|
||||
0x00, 0x00, 0x1C, 0x1C, 0x64, 0xE4, 0xCC, 0x44, 0x14, 0x0C, 0x10, 0x0C, 0x18, 0x08, 0x88, 0x84, 0x84, 0x44, 0x8E,
|
||||
0x47, 0x0F, 0x44, 0x09, 0x07, 0x18, 0x08, 0x30, 0x10, 0x40, 0x60, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0xC0, 0x60,
|
||||
0xF8, 0x18, 0x7C, 0x84, 0xBE, 0x42, 0xFC, 0x64, 0xD8, 0x58, 0xC0, 0x20, 0x60, 0x20, 0x60, 0x20, 0xE0, 0x20, 0xD0,
|
||||
0x70, 0x7C, 0x8C, 0x63, 0x83, 0xC9, 0xC0, 0x1F, 0x3F, 0x80, 0xC0, 0x20, 0x30, 0x08, 0x08, 0x08, 0x04, 0x0C, 0x04,
|
||||
0x1C, 0x02, 0xFE, 0xE2, 0x0E, 0x12, 0x06, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x08, 0x0A, 0x04, 0x12, 0x14, 0x14, 0x28,
|
||||
0x24, 0x98, 0xC8, 0xF0, 0x10, 0xC0, 0x60, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x40, 0x00, 0x80, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
// It has +128 since we are loading Mew sprites starting at position 128
|
||||
// to prevent collisions with the font sprites.
|
||||
const unsigned char mew_map[] =
|
||||
{
|
||||
0x94,0x94,0x94,0x8b,0x90,0x94,0x83,0x87,0x8c,0x91,
|
||||
0x80,0x84,0x88,0x8d,0x92,0x81,0x85,0x89,0x8e,0x94,
|
||||
0x82,0x86,0x8a,0x8f,0x93
|
||||
const unsigned char mew_map[] = {
|
||||
0x94, 0x94, 0x94, 0x8b, 0x90, 0x94, 0x83, 0x87, 0x8c, 0x91, 0x80, 0x84, 0x88, 0x8d, 0x92, 0x81, 0x85, 0x89, 0x8e,
|
||||
0x94, 0x82, 0x86, 0x8a, 0x8f, 0x93
|
||||
};
|
||||
|
||||
enum connection_state_t connection_state = NOT_CONNECTED;
|
||||
|
|
@ -82,31 +55,31 @@ uint8_t INPUT_BLOCK[418];
|
|||
uint8_t DATA_BLOCK[418];
|
||||
int trade_pokemon = -1;
|
||||
unsigned char name[11] = {
|
||||
pokechar_E,
|
||||
pokechar_U,
|
||||
pokechar_R,
|
||||
pokechar_O,
|
||||
pokechar_P,
|
||||
pokechar_E,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_E,
|
||||
pokechar_U,
|
||||
pokechar_R,
|
||||
pokechar_O,
|
||||
pokechar_P,
|
||||
pokechar_E,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE
|
||||
};
|
||||
unsigned char nicknames[11] = {
|
||||
// Pokemon Nickname
|
||||
pokechar_M,
|
||||
pokechar_E,
|
||||
pokechar_W,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
// Pokemon Nickname
|
||||
pokechar_M,
|
||||
pokechar_E,
|
||||
pokechar_W,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE,
|
||||
pokechar_STOP_BYTE
|
||||
};
|
||||
|
||||
typedef struct TraderPacket {
|
||||
|
|
@ -121,50 +94,50 @@ typedef struct TraderPacket {
|
|||
|
||||
void party_member_to_bytes(struct PartyMember *pPartyMember, uint8_t *out) {
|
||||
uint8_t res[44] = {
|
||||
pPartyMember->pokemon,
|
||||
(uint8_t) (pPartyMember->current_hp >> 8),
|
||||
(uint8_t) (pPartyMember->current_hp & 0x00FF),
|
||||
pPartyMember->level,
|
||||
pPartyMember->status,
|
||||
pPartyMember->type1,
|
||||
pPartyMember->type2,
|
||||
pPartyMember->catch_rate_or_held_item,
|
||||
pPartyMember->move1,
|
||||
pPartyMember->move2,
|
||||
pPartyMember->move3,
|
||||
pPartyMember->move4,
|
||||
(uint8_t) (pPartyMember->original_trainer_id >> 8),
|
||||
(uint8_t) (pPartyMember->original_trainer_id & 0x00FF),
|
||||
(uint8_t) ((pPartyMember->experience & 0x00FF0000) >> 16),
|
||||
(uint8_t) ((pPartyMember->experience & 0x0000FF00) >> 8),
|
||||
(uint8_t) (pPartyMember->experience & 0x000000FF),
|
||||
(uint8_t) (pPartyMember->HP_ev >> 8),
|
||||
(uint8_t) (pPartyMember->HP_ev & 0x00FF),
|
||||
(uint8_t) (pPartyMember->attack_ev >> 8),
|
||||
(uint8_t) (pPartyMember->attack_ev & 0x00FF),
|
||||
(uint8_t) (pPartyMember->defense_ev >> 8),
|
||||
(uint8_t) (pPartyMember->defense_ev & 0x00FF),
|
||||
(uint8_t) (pPartyMember->speed_ev >> 8),
|
||||
(uint8_t) (pPartyMember->speed_ev & 0x00FF),
|
||||
(uint8_t) (pPartyMember->special_ev >> 8),
|
||||
(uint8_t) (pPartyMember->special_ev & 0x00FF),
|
||||
(uint8_t) (((pPartyMember->attack_iv & 0xF) << 4) | (pPartyMember->defense_iv & 0xF)),
|
||||
(uint8_t) (((pPartyMember->speed_iv & 0xF) << 4) | (pPartyMember->special_iv & 0xF)),
|
||||
pPartyMember->move1_pp,
|
||||
pPartyMember->move2_pp,
|
||||
pPartyMember->move3_pp,
|
||||
pPartyMember->move4_pp,
|
||||
pPartyMember->level,
|
||||
(uint8_t) (pPartyMember->max_hp >> 8),
|
||||
(uint8_t) (pPartyMember->max_hp & 0x00FF),
|
||||
(uint8_t) (pPartyMember->attack >> 8),
|
||||
(uint8_t) (pPartyMember->attack & 0x00FF),
|
||||
(uint8_t) (pPartyMember->defense >> 8),
|
||||
(uint8_t) (pPartyMember->defense & 0x00FF),
|
||||
(uint8_t) (pPartyMember->speed >> 8),
|
||||
(uint8_t) (pPartyMember->speed & 0x00FF),
|
||||
(uint8_t) (pPartyMember->special >> 8),
|
||||
(uint8_t) (pPartyMember->special & 0x00FF),
|
||||
pPartyMember->pokemon,
|
||||
(uint8_t)(pPartyMember->current_hp >> 8),
|
||||
(uint8_t)(pPartyMember->current_hp & 0x00FF),
|
||||
pPartyMember->level,
|
||||
pPartyMember->status,
|
||||
pPartyMember->type1,
|
||||
pPartyMember->type2,
|
||||
pPartyMember->catch_rate_or_held_item,
|
||||
pPartyMember->move1,
|
||||
pPartyMember->move2,
|
||||
pPartyMember->move3,
|
||||
pPartyMember->move4,
|
||||
(uint8_t)(pPartyMember->original_trainer_id >> 8),
|
||||
(uint8_t)(pPartyMember->original_trainer_id & 0x00FF),
|
||||
(uint8_t)((pPartyMember->experience & 0x00FF0000) >> 16),
|
||||
(uint8_t)((pPartyMember->experience & 0x0000FF00) >> 8),
|
||||
(uint8_t)(pPartyMember->experience & 0x000000FF),
|
||||
(uint8_t)(pPartyMember->HP_ev >> 8),
|
||||
(uint8_t)(pPartyMember->HP_ev & 0x00FF),
|
||||
(uint8_t)(pPartyMember->attack_ev >> 8),
|
||||
(uint8_t)(pPartyMember->attack_ev & 0x00FF),
|
||||
(uint8_t)(pPartyMember->defense_ev >> 8),
|
||||
(uint8_t)(pPartyMember->defense_ev & 0x00FF),
|
||||
(uint8_t)(pPartyMember->speed_ev >> 8),
|
||||
(uint8_t)(pPartyMember->speed_ev & 0x00FF),
|
||||
(uint8_t)(pPartyMember->special_ev >> 8),
|
||||
(uint8_t)(pPartyMember->special_ev & 0x00FF),
|
||||
(uint8_t)(((pPartyMember->attack_iv & 0xF) << 4) | (pPartyMember->defense_iv & 0xF)),
|
||||
(uint8_t)(((pPartyMember->speed_iv & 0xF) << 4) | (pPartyMember->special_iv & 0xF)),
|
||||
pPartyMember->move1_pp,
|
||||
pPartyMember->move2_pp,
|
||||
pPartyMember->move3_pp,
|
||||
pPartyMember->move4_pp,
|
||||
pPartyMember->level,
|
||||
(uint8_t)(pPartyMember->max_hp >> 8),
|
||||
(uint8_t)(pPartyMember->max_hp & 0x00FF),
|
||||
(uint8_t)(pPartyMember->attack >> 8),
|
||||
(uint8_t)(pPartyMember->attack & 0x00FF),
|
||||
(uint8_t)(pPartyMember->defense >> 8),
|
||||
(uint8_t)(pPartyMember->defense & 0x00FF),
|
||||
(uint8_t)(pPartyMember->speed >> 8),
|
||||
(uint8_t)(pPartyMember->speed & 0x00FF),
|
||||
(uint8_t)(pPartyMember->special >> 8),
|
||||
(uint8_t)(pPartyMember->special & 0x00FF),
|
||||
};
|
||||
for (size_t i = 0; i < 44; i++) {
|
||||
out[i] = res[i];
|
||||
|
|
@ -173,14 +146,14 @@ void party_member_to_bytes(struct PartyMember *pPartyMember, uint8_t *out) {
|
|||
|
||||
void selected_pokemon_to_bytes(struct SelectedPokemon *pSelectedPokemon, uint8_t *out) {
|
||||
uint8_t res[8] = {
|
||||
pSelectedPokemon->number,
|
||||
pSelectedPokemon->pokemon[0],
|
||||
pSelectedPokemon->pokemon[1],
|
||||
pSelectedPokemon->pokemon[2],
|
||||
pSelectedPokemon->pokemon[3],
|
||||
pSelectedPokemon->pokemon[4],
|
||||
pSelectedPokemon->pokemon[5],
|
||||
0xFF,
|
||||
pSelectedPokemon->number,
|
||||
pSelectedPokemon->pokemon[0],
|
||||
pSelectedPokemon->pokemon[1],
|
||||
pSelectedPokemon->pokemon[2],
|
||||
pSelectedPokemon->pokemon[3],
|
||||
pSelectedPokemon->pokemon[4],
|
||||
pSelectedPokemon->pokemon[5],
|
||||
0xFF,
|
||||
};
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
out[i] = res[i];
|
||||
|
|
@ -196,7 +169,7 @@ void trader_packet_to_bytes(struct TraderPacket *pTraderPacket, uint8_t *out) {
|
|||
|
||||
// Serialize the data
|
||||
for (size_t i = 0; i < NAME_LEN; i++) {
|
||||
name_bytes[i] = (uint8_t) pTraderPacket->name[i];
|
||||
name_bytes[i] = (uint8_t)pTraderPacket->name[i];
|
||||
}
|
||||
|
||||
// Calculate the selected_pokemon and pokemon w/ stats and such
|
||||
|
|
@ -206,21 +179,20 @@ void trader_packet_to_bytes(struct TraderPacket *pTraderPacket, uint8_t *out) {
|
|||
|
||||
// Full Party Data (all stats and such)
|
||||
for (size_t j = 0; j < POKE_SIZE; j++) {
|
||||
pokemon_bytes[(i * POKE_SIZE) + j] = (uint8_t) poke[j];
|
||||
pokemon_bytes[(i * POKE_SIZE) + j] = (uint8_t)poke[j];
|
||||
}
|
||||
}
|
||||
selected_pokemon_to_bytes(&pTraderPacket->selected_pokemon, selected_pokemon_bytes);
|
||||
|
||||
|
||||
for (size_t i = 0; i < PARTY_SIZE; i++) {
|
||||
for (size_t j = 0; j < NAME_LEN; j++) {
|
||||
original_trainer_names_bytes[(i * NAME_LEN) + j] = (uint8_t) pTraderPacket->original_trainer_names[i][j];
|
||||
original_trainer_names_bytes[(i * NAME_LEN) + j] = (uint8_t)pTraderPacket->original_trainer_names[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < PARTY_SIZE; i++) {
|
||||
for (size_t j = 0; j < NAME_LEN; j++) {
|
||||
pokemon_nicknames_bytes[(i * NAME_LEN) + j] = (uint8_t) pTraderPacket->pokemon_nicknames[i][j];
|
||||
pokemon_nicknames_bytes[(i * NAME_LEN) + j] = (uint8_t)pTraderPacket->pokemon_nicknames[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -252,19 +224,16 @@ void trader_packet_to_bytes(struct TraderPacket *pTraderPacket, uint8_t *out) {
|
|||
}
|
||||
|
||||
// get a seed to be used for random generation by xoring values from ram which are pseudorandom on startup.
|
||||
uint16_t get_ram_seed(void)
|
||||
{
|
||||
uint16_t* p = (uint16_t*) 0xC000;
|
||||
uint16_t get_ram_seed(void) {
|
||||
uint16_t *p = (uint16_t *)0xC000;
|
||||
uint16_t sum = 0;
|
||||
for (uint16_t i = 0; i < 0x1FFF; i++)
|
||||
{
|
||||
for (uint16_t i = 0; i < 0x1FFF; i++) {
|
||||
sum ^= p[i];
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
void fill_pokemon_team(void)
|
||||
{
|
||||
void fill_pokemon_team(void) {
|
||||
/**
|
||||
* Trader Packet Init
|
||||
*/
|
||||
|
|
@ -288,7 +257,7 @@ void fill_pokemon_team(void)
|
|||
// - https://projectpokemon.org/home/forums/topic/56562-uk-mew-from-julyaugust-2000/?do=findComment&comment=254955
|
||||
// - https://projectpokemon.org/home/forums/topic/37431-gen-i-v-event-contributions-thread/?do=findComment&comment=255300
|
||||
//
|
||||
// D-J one is not clear that it was legit, only EUROPE. Notes from Suloku about D-J one:
|
||||
// D-J one is not clear that it was legit, only EUROPE. Notes from Suloku about D-J one (SPANISH):
|
||||
//
|
||||
// El caso es que al final apareció el verdadero mew que repartieron en madrid, OT EUROPE.
|
||||
// Lo tenía un jugador que después de muchos años volvio a pokemon, y ya en la época tenía métodos de backup de
|
||||
|
|
@ -304,33 +273,22 @@ void fill_pokemon_team(void)
|
|||
pPartyMember->level = 5;
|
||||
pPartyMember->status = NONE;
|
||||
pPartyMember->type1 = PSYCHIC_TYPE;
|
||||
pPartyMember->type2 = PSYCHIC_TYPE; // If only one type, copy the first
|
||||
pPartyMember->catch_rate_or_held_item = 45; // R/G/B/Y (catch rate), G/S/C (held item), and Stadium (held item) use this byte differently
|
||||
pPartyMember->type2 = PSYCHIC_TYPE;
|
||||
pPartyMember->catch_rate_or_held_item = 45;
|
||||
pPartyMember->move1 = POUND;
|
||||
pPartyMember->move2 = 0x0;
|
||||
pPartyMember->move3 = 0x0;
|
||||
pPartyMember->move4 = 0x0;
|
||||
pPartyMember->original_trainer_id = (randw() % 65535) + 1;
|
||||
|
||||
// - Experience is complicated. You must look up the Pokemon you are trying to trade
|
||||
// in the following table and apply the experience points that match the level.
|
||||
// EXP LVL Table for gen 1: https://pwo-wiki.info/index.php/Generation_I_Experience_Charts
|
||||
// That source was the best I could find for Gen 1. If you find another, submit a PR or open an issue and I'll fix it
|
||||
// - Experience is a 24bit number, we will be dropping the MSB to acheive that
|
||||
pPartyMember->experience = 135;
|
||||
|
||||
// Effort Values
|
||||
// These are very specific to the Pokemon and who they battled in the past or what vitamins they were fed
|
||||
// Luckily, these get recalculated when you level them up, or when you put them in a box and then put them back in your party
|
||||
// For this example, I will take the max value and scale it to the level (65535 * 0.40) = 26214
|
||||
pPartyMember->HP_ev = 0;
|
||||
pPartyMember->attack_ev = 0;
|
||||
pPartyMember->defense_ev = 0;
|
||||
pPartyMember->speed_ev = 0;
|
||||
pPartyMember->special_ev = 0;
|
||||
|
||||
// IVs are a 4 bit number, so the max value is 15 (0-15 = 0b0000-0b1111 = 0x0-0xF)
|
||||
// These have been broken out for legibility, but will be condensed to only 2 bytes
|
||||
pPartyMember->attack_iv = 10;
|
||||
pPartyMember->defense_iv = 1;
|
||||
pPartyMember->speed_iv = 12;
|
||||
|
|
@ -363,11 +321,9 @@ void fill_pokemon_team(void)
|
|||
|
||||
uint8_t handle_byte(uint8_t in, size_t *counter) {
|
||||
static uint8_t out;
|
||||
switch (connection_state)
|
||||
{
|
||||
switch (connection_state) {
|
||||
case NOT_CONNECTED:
|
||||
switch (in)
|
||||
{
|
||||
switch (in) {
|
||||
case PKMN_MASTER:
|
||||
out = PKMN_SLAVE;
|
||||
break;
|
||||
|
|
@ -386,8 +342,7 @@ uint8_t handle_byte(uint8_t in, size_t *counter) {
|
|||
break;
|
||||
|
||||
case CONNECTED:
|
||||
switch (in)
|
||||
{
|
||||
switch (in) {
|
||||
case PKMN_CONNECTED_TIME_CAPSULE:
|
||||
out = PKMN_TIME_CAPSULE_SELECT;
|
||||
break;
|
||||
|
|
@ -399,8 +354,9 @@ uint8_t handle_byte(uint8_t in, size_t *counter) {
|
|||
out = PKMN_TRADE_CENTRE;
|
||||
break;
|
||||
case PKMN_COLOSSEUM:
|
||||
// This case is not built out and I have no intention to do it
|
||||
// Not handled, everything will just be mirrored.
|
||||
connection_state = COLOSSEUM;
|
||||
out = PKMN_COLOSSEUM;
|
||||
break;
|
||||
case PKMN_BREAK_LINK:
|
||||
connection_state = NOT_CONNECTED;
|
||||
|
|
@ -490,7 +446,7 @@ uint8_t handle_byte(uint8_t in, size_t *counter) {
|
|||
trade_state = TRADE_DONE;
|
||||
} else if (trade_state == TRADE_DONE && (in & 0x60) == 0x60) {
|
||||
out = in;
|
||||
if (in == 0x61) {
|
||||
if (in == 0x61) {
|
||||
trade_pokemon = -1;
|
||||
trade_state = TRADE_WAIT;
|
||||
} else {
|
||||
|
|
@ -526,8 +482,7 @@ uint8_t sio_exchange_slave(uint8_t b) {
|
|||
return SB_REG;
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
void main(void) {
|
||||
// Read from RAM to generate the seed (from 0xC000 to 0xDFFF) for later pseudo-random TID generation.
|
||||
initrand(get_ram_seed());
|
||||
|
||||
|
|
@ -546,7 +501,7 @@ void main(void)
|
|||
|
||||
SC_REG = SIOF_CLOCK_INT;
|
||||
uint8_t in = 0xff;
|
||||
while(TRUE) {
|
||||
while (TRUE) {
|
||||
in = sio_exchange_slave(handle_byte(in, &trade_counter));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user