Continuing transfer menu implementation

This commit is contained in:
Remnants of Forgotten Disney 2024-04-02 12:19:06 -05:00
parent 13450924c2
commit a27f1c2c37
23 changed files with 537 additions and 48 deletions

3
graphics/box_select.grit Normal file
View File

@ -0,0 +1,3 @@
#
# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48.
-gB4 -ps32 -pe48

BIN
graphics/box_select.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 879 B

View File

@ -0,0 +1,3 @@
#
# menu sprites : 4bpp, not compressed. Pallet 1, copy from 0 to 16.
-gB4 -ps0 -pe16

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

20
include/box_menu.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef BOX_MENU_H
#define BOX_MENU_H
#include <tonc.h>
#include <vector>
#include "string.h"
#include "button_handler.h"
#include "pokemon.h"
#include "string_view"
#include "pokemon_party.h"
class Box_Menu
{
public:
Box_Menu();
int box_main(Pokemon_Party party_data);
private:
};
#endif

View File

@ -1,9 +1,9 @@
#ifndef DEBUG_MODE_H
#define DEBUG_MODE_H
#define DEBUG_MODE true
#define IGNORE_GAME_PAK false
#define IGNORE_LINK_CABLE false
#define DEBUG_MODE false
#define IGNORE_GAME_PAK true
#define IGNORE_LINK_CABLE true
#define IGNORE_MG_E4_FLAGS true
#define DEBUG_GAME RUBY_ID

View File

@ -45,4 +45,5 @@ private:
int bottom_offset;
bool cancel_enabled;
};
#endif

View File

@ -3,6 +3,7 @@
#include <tonc.h>
#include "random.h"
#include "global_frame_controller.h"
#define POKEMON_SIZE 80
@ -13,6 +14,13 @@
#define GEN2_JPN_SIZE 383
#define GEN2_INT_SIZE 444
struct Simplified_Pokemon{
byte dex_number;
byte met_level;
byte nickname[10];
bool is_valid;
};
class Pokemon
{
public:
@ -36,6 +44,7 @@ public:
byte get_dex_number();
bool get_validity();
bool get_is_new();
Simplified_Pokemon get_simple_pkmn();
private:

View File

@ -4,21 +4,21 @@
#include <tonc.h>
#include <string>
#define erratic_max 600000
#define fast_max 800000
#define med_fast_max 1000000
#define med_slow_max 1059860
#define slow_max 1250000
#define flux_max 1640000
#define erratic_max 600000
#define fast_max 800000
#define med_fast_max 1000000
#define med_slow_max 1059860
#define slow_max 1250000
#define flux_max 1640000
#define INTERNATIONAL 0
#define JPN_ID 1
#define ENG_ID 2
#define FRE_ID 3
#define ITA_ID 4
#define GER_ID 5
#define SPA_ID 7
#define KOR_ID 8
#define JPN_ID 1
#define ENG_ID 2
#define FRE_ID 3
#define ITA_ID 4
#define GER_ID 5
#define SPA_ID 7
#define KOR_ID 8
#define RED_GREEN_ID 0
#define RED_BLUE_ID 1
@ -29,7 +29,6 @@
#define MAX_PKMN_IN_BOX 30
extern const u8 EXP_MAX[252];
extern const u32 EXP_TYPES[6];
extern const int GENDER_THRESHOLDS[2][8];
@ -41,9 +40,8 @@ extern const std::string_view NAMES[252];
extern const u16 JPN_NAMES[252][6];
extern const u8 EVOLUTIONS[252];
extern const u8 POWER_POINTS[252];
extern const u8 MENU_SPRITES[252];
extern const byte gen_1_index_array[191];
//extern const byte gen_1_char_array[0x80];
//extern const byte gen_2_char_array[0x80];
extern const u16 gen_1_Jpn_char_array[256];
extern const u16 gen_1_Eng_char_array[256];
extern const u16 gen_1_FreGer_char_array[256];

View File

@ -12,6 +12,7 @@ class Pokemon_Party
public:
Pokemon_Party();
void start_link();
void continue_link();
int get_last_error();
Pokemon get_converted_pkmn(int index);
bool get_has_new_pkmn();
@ -20,6 +21,10 @@ public:
int get_lang();
bool load_payload();
PAYLOAD curr_payload;
void show_sprites();
Simplified_Pokemon simple_pkmn_array[30];
Simplified_Pokemon get_simple_pkmn(int index);
void fill_simple_pkmn_array();
private:
byte box_data_array[0x462];

View File

@ -34,8 +34,9 @@
#define DIA_WHAT_LANG 25
#define DIA_ASK_QUEST 26
#define DIA_NO_PAYLOAD 27
#define DIA_IN_BOX 28
#define DIA_SIZE 28
#define DIA_SIZE 29
#define DIA_END DIA_SIZE
// Commands
@ -51,8 +52,12 @@
#define CMD_LANG_MENU DIA_END + 9
#define CMD_SLIDE_PROF_LEFT DIA_END + 10
#define CMD_SLIDE_PROF_RIGHT DIA_END + 11
#define CMD_SHOW_LARGE_TEXTBOX DIA_END + 12
#define CMD_HIDE_LARGE_TEXTBOX DIA_END + 13
#define CMD_CONTINUE_LINK DIA_END + 14
#define CMD_BOX_MENU DIA_END + 15
#define CMD_SIZE 12
#define CMD_SIZE 16
#define CMDS_END DIA_END + CMD_SIZE
// Conditionals

View File

@ -2,6 +2,9 @@
#define SPRITE_DATA_H
#include <tonc.h>
#include "pokemon.h"
#include "pokemon_data.h"
#include "pokemon_party.h"
extern OBJ_ATTR obj_buffer[128];
extern OBJ_AFFINE *obj_aff_buffer;
@ -74,10 +77,21 @@ extern OBJ_ATTR *button_crystal_left;
extern OBJ_ATTR *button_crystal_right;
#include "button_game_select_edge.h"
#include "duel_frame_menu_sprites.h"
extern OBJ_ATTR *party_sprites[30];
extern const unsigned short frame_one_pal[16];
extern const unsigned short frame_two_pal[16];
#include "box_select.h"
extern OBJ_ATTR *box_select;
#define BG2VOF_SMALL_TEXTBOX 96
#define BG2VOF_LARGE_TEXTBOX 0
#define METR_PAL 0
#define PROF_PAL 1
#define BTN_PAL 2
#define BTN_LIT_PAL 3
#define MENU_SPRITE_PAL 4
void load_sprite(OBJ_ATTR *sprite, const unsigned int objTiles[], int objTilesLen,
u32 &tile_id, u32 pal_bank, int attr0, int attr1, u32 priority);
@ -86,12 +100,6 @@ void load_textbox_background();
void load_opening_background();
void load_eternal_sprites();
void load_temp_sprites(int sprite_batch_id);
void load_btn_lang_eng();
void load_btn_lang_fre();
void load_btn_lang_ita();
void load_btn_lang_ger();
void load_btn_lang_spa();
void load_btn_lang_kor();
void load_lang_arrow();
void load_temp_box_sprites(Pokemon_Party party_data);
#endif

68
source/box_menu.cpp Normal file
View File

@ -0,0 +1,68 @@
#include <tonc.h>
#include "main_menu.h"
#include "button_handler.h"
#include "save_data_manager.h"
#include "global_frame_controller.h"
#include "string"
#include "sprite_data.h"
#include "box_menu.h"
#include "pokemon_data.h"
Box_Menu::Box_Menu(){};
int Box_Menu::box_main(Pokemon_Party party_data)
{
REG_BG0CNT = (REG_BG0CNT & ~BG_PRIO_MASK) | BG_PRIO(3);
REG_BG2CNT = (REG_BG2CNT & ~BG_PRIO_MASK) | BG_PRIO(2);
REG_BG2VOFS = 0;
load_temp_box_sprites(party_data);
int x = 0;
int y = 0;
bool update_pos = true;
obj_unhide(box_select, 0);
while (true)
{
if (key_hit(KEY_LEFT) && (x > 0))
{
x--;
update_pos = true;
}
else if (key_hit(KEY_RIGHT) && (x < 9))
{
x++;
update_pos = true;
}
else if (key_hit(KEY_UP) && y > 0)
{
y--;
update_pos = true;
}
else if (key_hit(KEY_DOWN) && (y < 2))
{
y++;
update_pos = true;
}
if (update_pos)
{
int index = x + (y * 10);
obj_set_pos(box_select, 40 + (x * 16), 24 + (y * 16));
tte_erase_rect(40, 72, 220, 88);
if (party_data.get_simple_pkmn(index).is_valid)
{
char nickname[10] = {'t', 'e', 's', 't', 'i', 'n', 'g'};
for (int i = 0; i < 10; i++)
{
nickname[i] = gen_3_Intern_char_array[party_data.get_simple_pkmn(index).nickname[i]];
}
tte_set_pos(40, 72);
tte_write(nickname);
tte_set_pos(56, 80);
tte_write(NAMES[party_data.get_simple_pkmn(index).dex_number].data());
tte_set_pos(146, 80);
tte_write("Lv: ");
tte_write(std::to_string(party_data.get_simple_pkmn(index).met_level).c_str());
}
}
global_next_frame();
}
}

View File

@ -5,6 +5,7 @@
#include "background_engine.h"
#include "text_engine.h"
#include "sprite_data.h"
#include "string.h"
int global_frame_count = 0;
@ -18,6 +19,14 @@ void global_next_frame()
oam_copy(oam_mem, obj_buffer, num_sprites);
VBlankIntrWait();
// mmFrame(); //Music
if (global_frame_count % 60 == 0)
{
memcpy(pal_obj_mem + (MENU_SPRITE_PAL * 16), frame_one_pal, 32);
}
else if (global_frame_count % 60 == 30)
{
memcpy(pal_obj_mem + (MENU_SPRITE_PAL * 16), frame_two_pal, 32);
}
global_frame_count++;
};

View File

@ -20,6 +20,8 @@ Button_Menu::Button_Menu(int nRows, int nColumns, int nButton_width, int nButton
cancel_enabled = enable_cancel;
}
void Button_Menu::set_xy_min_max(int nX_min, int nX_max, int nY_min, int nY_max)
{
x_min = nX_min;

View File

@ -14,9 +14,6 @@ static u8 lanette_wonder_card[0x14E] = {
bool inject_mystery(Pokemon_Party &incoming_box_data)
{
int validity_array[MAX_PKMN_IN_BOX];
int dex_array[MAX_PKMN_IN_BOX];
mystery_gift_script script;
script.build_script(incoming_box_data);
u32 checksum = 0;
@ -73,13 +70,11 @@ bool inject_mystery(Pokemon_Party &incoming_box_data)
global_memory_buffer[curr_index] = curr_pkmn.get_gen_3_data(curr_byte);
curr_index++;
}
validity_array[i] = curr_pkmn.get_validity();
dex_array[i] = curr_pkmn.get_dex_number();
}
for (int i = 0; i < MAX_PKMN_IN_BOX; i++) // Add in the dex numbers
{
global_memory_buffer[curr_index] = dex_array[i];
global_memory_buffer[curr_index] = incoming_box_data.get_simple_pkmn(curr_index).dex_number;
curr_index++;
}
@ -97,7 +92,7 @@ bool inject_mystery(Pokemon_Party &incoming_box_data)
int curr_flag;
curr_flag = curr_rom.pkmn_collected_flag_start + i;
global_memory_buffer[(curr_rom.offset_flags + (curr_flag / 8)) % 0xF80] &= ~(1 << (curr_flag % 8)); // Reset the flag
if (validity_array[i])
if (incoming_box_data.get_simple_pkmn(i).is_valid)
{
global_memory_buffer[(curr_rom.offset_flags + (curr_flag / 8)) % 0xF80] |= (1 << (curr_flag % 8)); // Set flag accordingly
}

View File

@ -85,8 +85,8 @@ void Pokemon::load_data(int index, byte *party_data, int game, int lang)
switch (gen)
{
case 1:
//tte_write(std::to_string(party_data[1121]).c_str());
//while (true){};
// tte_write(std::to_string(party_data[1121]).c_str());
// while (true){};
species_index_party = party_data[party_species_offset];
species_index_struct = party_data[box_struct_offset + 0x00];
met_level = party_data[box_struct_offset + 0x03];
@ -388,6 +388,7 @@ void Pokemon::convert_to_gen_three()
// Puts the four data chunks into their correct locations based on the PID
alocate_data_chunks(data_section_G, data_section_A, data_section_E, data_section_M);
global_next_frame();
}
void Pokemon::copy_from_to(byte *source, byte *destination, int size, bool reverse_endian)
@ -650,4 +651,18 @@ bool Pokemon::get_validity()
bool Pokemon::get_is_new()
{
return (is_valid ? is_new : false);
}
Simplified_Pokemon Pokemon::get_simple_pkmn()
{
//
Simplified_Pokemon curr_pkmn;
curr_pkmn.dex_number = get_dex_number();
curr_pkmn.met_level = met_level;
for (int i = 0; i < 10; i++)
{
curr_pkmn.nickname[i] = nickname[i];
}
curr_pkmn.is_valid = get_validity();
return curr_pkmn;
}

View File

@ -5129,3 +5129,258 @@ const u8 POWER_POINTS[252]{
15, // Whirlpool
10, // Beat-up
};
const u8 MENU_SPRITES[252] = {
0, // Offset the list to remove "off by one" errors
22, // Bulbasaur
22, // Ivysaur
22, // Venusaur
23, // Charmander
23, // Charmeleon
38, // Charizard
21, // Squirtle
21, // Wartortle
21, // Blastoise
24, // Caterpie
24, // Metapod
30, // Butterfree
24, // Weedle
24, // Kakuna
11, // Beedrill
7, // Pidgey
7, // Pidgeotto
7, // Pidgeot
15, // Rattata
15, // Raticate
7, // Spearow
7, // Fearow
19, // Ekans
19, // Arbok
4, // Pikachu
4, // Raichu
8, // Sandshrew
8, // Sandslash
15, // Nidoran♀
15, // Nidorina
8, // Nidoqueen
15, // Nidoran♂
15, // Nidorino
8, // Nidoking
9, // Clefairy
9, // Clefable
15, // Vulpix
15, // Ninetales
2, // Jigglypuff
2, // Wigglytuff
31, // Zubat
31, // Golbat
10, // Oddish
10, // Gloom
10, // Vileplume
11, // Paras
11, // Parasect
24, // Venonat
30, // Venomoth
3, // Diglett
3, // Dugtrio
15, // Meowth
15, // Persian
8, // Psyduck
8, // Golduck
27, // Mankey
27, // Primeape
15, // Growlithe
15, // Arcanine
1, // Poliwag
1, // Poliwhirl
1, // Poliwrath
14, // Abra
14, // Kadabra
14, // Alakazam
27, // Machop
27, // Machoke
27, // Machamp
10, // Bellsprout
10, // Weepinbell
10, // Victreebel
29, // Tentacool
29, // Tentacruel
26, // Geodude
26, // Graveler
26, // Golem
16, // Ponyta
16, // Rapidash
36, // Slowpoke
36, // Slowbro
20, // Magnemite
20, // Magneton
7, // Farfetch'd
7, // Doduo
7, // Dodrio
13, // Seel
13, // Dewgong
18, // Grimer
18, // Muk
37, // Shellder
37, // Cloyster
12, // Gastly
12, // Haunter
12, // Gengar
19, // Onix
14, // Drowzee
14, // Hypno
17, // Krabby
17, // Kingler
20, // Voltorb
20, // Electrode
10, // Exeggcute
10, // Exeggutor
8, // Cubone
8, // Marowak
27, // Hitmonlee
27, // Hitmonchan
8, // Lickitung
18, // Koffing
18, // Weezing
16, // Rhyhorn
8, // Rhydon
9, // Chansey
10, // Tangela
8, // Kangaskhan
6, // Horsea
6, // Seadra
6, // Goldeen
6, // Seaking
5, // Staryu
5, // Starmie
14, // Mr. Mime
11, // Scyther
14, // Jynx
14, // Electabuzz
14, // Magmar
11, // Pinsir
16, // Tauros
6, // Magikarp
35, // Gyarados
13, // Lapras
18, // Ditto
15, // Eevee
15, // Vaporeon
15, // Jolteon
15, // Flareon
20, // Porygon
17, // Omanyte
17, // Omastar
17, // Kabuto
17, // Kabutops
7, // Aerodactyl
32, // Snorlax
7, // Articuno
7, // Zapdos
7, // Moltres
19, // Dratini
19, // Dragonair
38, // Dragonite
14, // Mewtwo
14, // Mew
10, // Chikorita
10, // Bayleef
10, // Meganium
15, // Cyndaquil
15, // Quilava
15, // Typhlosion
8, // Totodile
8, // Croconaw
8, // Feraligatr
15, // Sentret
15, // Furret
7, // Hoothoot
7, // Noctowl
11, // Ledyba
11, // Ledian
11, // Spinarak
11, // Ariados
31, // Crobat
6, // Chinchou
6, // Lanturn
4, // Pichu
9, // Cleffa
2, // Igglybuff
9, // Togepi
7, // Togetic
7, // Natu
7, // Xatu
15, // Mareep
8, // Flaaffy
8, // Ampharos
10, // Bellossom
2, // Marill
2, // Azumarill
27, // Sudowoodo
1, // Politoed
10, // Hoppip
10, // Skiploom
10, // Jumpluff
8, // Aipom
10, // Sunkern
10, // Sunflora
11, // Yanma
8, // Wooper
8, // Quagsire
15, // Espeon
15, // Umbreon
7, // Murkrow
36, // Slowking
12, // Misdreavus
25, // Unown
12, // Wobbuffet
16, // Girafarig
11, // Pineco
11, // Forretress
19, // Dunsparce
11, // Gligar
19, // Steelix
8, // Snubbull
8, // Granbull
6, // Qwilfish
11, // Scizor
11, // Shuckle
11, // Heracross
15, // Sneasel
8, // Teddiursa
8, // Ursaring
18, // Slugma
18, // Magcargo
16, // Swinub
16, // Piloswine
17, // Corsola
6, // Remoraid
6, // Octillery
8, // Delibird
6, // Mantine
7, // Skarmory
15, // Houndour
15, // Houndoom
38, // Kingdra
16, // Phanpy
16, // Donphan
20, // Porygon2
16, // Stantler
8, // Smeargle
27, // Tyrogue
27, // Hitmontop
14, // Smoochum
14, // Elekid
14, // Magby
16, // Miltank
9, // Blissey
15, // Raikou
15, // Entei
15, // Suicune
8, // Larvitar
8, // Pupitar
8, // Tyranitar
34, // Lugia
33, // Ho-Oh
14, // Celebi
};

View File

@ -5,6 +5,8 @@
#include "debug_mode.h"
#include "mystery_gift_injector.h"
#include "payloads/base_payload_struct.h"
#include "sprite_data.h"
#include "box_menu.h"
const PAYLOAD *list_of_payloads[NUM_PAYLOADS] = {
&ENG_RED_BLUE
@ -18,7 +20,7 @@ byte debug_box_data[0x462] = {
// Pokemon 1-20
0x02, 0x70, 0x70, 0x70, 0x71, 0x71, 0x70, 0x71, 0x7B, 0x71, 0x71, 0x7C, 0x71, 0x71, 0x71, 0x71, 0x24, 0x24, 0xA5, 0x24, 0xFF,
// Pokemon list
0x02, 0x00, 0x11, 0x04, 0x00, 0x07, 0x03, 0xFF, 0x28, 0x51, 0x00, 0x00, 0x6F, 0xC6, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE6, 0xDE, 0x23, 0x28, 0x00, 0x00,
0x02, 0x00, 0x11, 100, 0x00, 0x07, 0x03, 0xFF, 0x28, 0x51, 0x00, 0x00, 0x6F, 0xC6, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE6, 0xDE, 0x23, 0x28, 0x00, 0x00,
0x70, 0x00, 0x12, 0x04, 0x00, 0x07, 0x03, 0xFF, 0x28, 0x51, 0x00, 0x00, 0x6F, 0xC6, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5D, 0xD8, 0x23, 0x28, 0x00, 0x00,
0x70, 0x00, 0x12, 0x04, 0x00, 0x07, 0x03, 0xFF, 0x28, 0x51, 0x00, 0x00, 0x6F, 0xC6, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x13, 0x23, 0x28, 0x00, 0x00,
0x70, 0x00, 0x0F, 0x03, 0x00, 0x07, 0x03, 0xFF, 0x28, 0x51, 0x00, 0x00, 0x6F, 0xC6, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDA, 0x81, 0x23, 0x28, 0x00, 0x00,
@ -99,6 +101,10 @@ void Pokemon_Party::start_link()
}
}
void Pokemon_Party::continue_link(){
last_error = loop(&box_data_array[0], &curr_payload);
}
int Pokemon_Party::get_last_error()
{
return last_error;
@ -110,6 +116,7 @@ Pokemon Pokemon_Party::get_converted_pkmn(int index)
converted_mon.load_data(index, box_data_array, game, lang);
converted_mon.convert_to_gen_three();
has_new_pkmn = has_new_pkmn || converted_mon.get_is_new();
simple_pkmn_array[index] = converted_mon.get_simple_pkmn();
return converted_mon;
}
@ -143,4 +150,18 @@ bool Pokemon_Party::load_payload(){
}
}
return false;
}
Simplified_Pokemon Pokemon_Party::get_simple_pkmn(int index){
return simple_pkmn_array[index];
}
void Pokemon_Party::fill_simple_pkmn_array(){
for (int index = 0; index < 30; index++){
Pokemon converted_mon;
converted_mon.load_data(index, box_data_array, game, lang);
converted_mon.convert_to_gen_three();
has_new_pkmn = has_new_pkmn || converted_mon.get_is_new();
simple_pkmn_array[index] = converted_mon.get_simple_pkmn();
}
}

View File

@ -7,6 +7,7 @@
#include "pokemon_data.h"
#include "mystery_gift_builder.h"
#include "global_frame_controller.h"
#include "box_menu.h"
#include <tonc.h>
int last_error;
@ -16,6 +17,7 @@ Button_Menu lang_select(2, 4, 40, 24, false);
Button_Menu game_select_def(2, 2, 72, 32, true);
Button_Menu game_select_jpn(3, 2, 72, 32, true);
Button_Menu game_select_kor(1, 1, 72, 32, true);
Box_Menu box_viewer;
script_obj script[SCRIPT_SIZE];
std::string_view dialogue[DIA_SIZE];
@ -42,6 +44,7 @@ void populate_dialogue()
dialogue[DIA_WHAT_GAME] = "And which Game Boy Pok@mon\ngame are you transferring\nfrom?";
dialogue[DIA_WHAT_LANG] = "What language is the Game\nBoy Pok@mon game that you're\ntransferring from?";
dialogue[DIA_NO_PAYLOAD] = "I'm sorry, but that version\nin that language is not\ncurrently supported.";
dialogue[DIA_IN_BOX] = "Great! Let's take a look at\nthe Pok@mon that will be\ntransfered.|Please remember, once a\nPok@mon is transfered, it\nCANNOT be returned to the\nGame Boy Game Pak.|Select transfer once you're\nready, or select cancel if\nyou want to keep the Pok@mon\non your Game Boy Game Pak.";
dialogue[DIA_ERROR_COLOSSEUM] = "It looks like you went to\nthe colosseum instead of the\ntrading room!|Let's try that again!";
dialogue[DIA_ERROR_COM_ENDED] = "Communication with the other\ndevice was terminated.|Let's try that again!";
@ -69,9 +72,6 @@ void populate_script()
script[DIA_PKMN_TO_COLLECT] = script_obj(dialogue[DIA_PKMN_TO_COLLECT], DIA_ASK_QUEST);
// Ask the user what game and language they're using
script[DIA_LETS_START] = script_obj(dialogue[DIA_LETS_START], DIA_START);
script[DIA_START] = script_obj(dialogue[DIA_START], CMD_START_LINK);
script[CMD_START_LINK] = script_obj(CMD_START_LINK, COND_ERROR_TIMEOUT_ONE);
script[DIA_WHAT_GAME] = script_obj(dialogue[DIA_WHAT_GAME], CMD_GAME_MENU);
script[CMD_GAME_MENU] = script_obj(CMD_GAME_MENU, COND_PAYLOAD_EXISTS, DIA_WHAT_LANG);
script[DIA_WHAT_LANG] = script_obj(dialogue[DIA_WHAT_LANG], CMD_LANG_MENU);
@ -83,6 +83,9 @@ void populate_script()
script[DIA_NO_PAYLOAD] = script_obj(dialogue[DIA_NO_PAYLOAD], DIA_WHAT_LANG);
// Initiate the transfer and check for errors
script[DIA_LETS_START] = script_obj(dialogue[DIA_LETS_START], DIA_START);
script[DIA_START] = script_obj(dialogue[DIA_START], CMD_START_LINK);
script[CMD_START_LINK] = script_obj(CMD_START_LINK, COND_ERROR_TIMEOUT_ONE);
script[COND_ERROR_TIMEOUT_ONE] = script_obj(COND_ERROR_TIMEOUT_ONE, COND_ERROR_TIMEOUT_TWO, DIA_ERROR_TIME_ONE);
script[DIA_ERROR_TIME_ONE] = script_obj(dialogue[DIA_ERROR_TIME_ONE], DIA_START);
script[COND_ERROR_TIMEOUT_TWO] = script_obj(COND_ERROR_TIMEOUT_TWO, COND_ERROR_COM_ENDED, DIA_ERROR_TIME_TWO);
@ -91,9 +94,15 @@ void populate_script()
script[DIA_ERROR_COM_ENDED] = script_obj(dialogue[DIA_ERROR_COM_ENDED], DIA_START);
script[COND_ERROR_COLOSSEUM] = script_obj(COND_ERROR_COLOSSEUM, COND_ERROR_DISCONNECT, DIA_ERROR_COLOSSEUM);
script[DIA_ERROR_COLOSSEUM] = script_obj(dialogue[DIA_ERROR_COLOSSEUM], DIA_START);
script[COND_ERROR_DISCONNECT] = script_obj(COND_ERROR_DISCONNECT, CMD_IMPORT_POKEMON, DIA_ERROR_DISCONNECT);
script[COND_ERROR_DISCONNECT] = script_obj(COND_ERROR_DISCONNECT, DIA_IN_BOX, DIA_ERROR_DISCONNECT);
script[DIA_ERROR_DISCONNECT] = script_obj(dialogue[DIA_ERROR_DISCONNECT], DIA_START);
// Pause the transfer and show the user their box data
script[DIA_IN_BOX] = script_obj(dialogue[DIA_IN_BOX], CMD_SHOW_LARGE_TEXTBOX);
script[CMD_SHOW_LARGE_TEXTBOX] = script_obj(CMD_SHOW_LARGE_TEXTBOX, CMD_BOX_MENU);
script[CMD_BOX_MENU] = script_obj(CMD_BOX_MENU, CMD_HIDE_LARGE_TEXTBOX);
script[CMD_HIDE_LARGE_TEXTBOX] = script_obj(CMD_HIDE_LARGE_TEXTBOX, DIA_LETS_START);
// Complete the transfer and give messages based on the transfered Pokemon
script[CMD_IMPORT_POKEMON] = script_obj(CMD_IMPORT_POKEMON, DIA_TRANS_GOOD, DIA_NO_VALID_PKMN);
script[DIA_NO_VALID_PKMN] = script_obj(dialogue[DIA_NO_VALID_PKMN], CMD_END_SCRIPT);
@ -193,6 +202,9 @@ bool run_conditional(int index)
case COND_PKMN_TO_COLLECT:
return compare_map_and_npc_data(curr_rom.map_bank, curr_rom.map_id, curr_rom.npc_id) && !read_flag(curr_rom.all_collected_flag) && !IGNORE_MG_E4_FLAGS;
case COND_PAYLOAD_EXISTS:
return party_data.load_payload();
case CMD_START_LINK:
party_data.start_link();
return true;
@ -268,8 +280,26 @@ bool run_conditional(int index)
}
return true;
case COND_PAYLOAD_EXISTS:
return party_data.load_payload();
case CMD_SHOW_LARGE_TEXTBOX:
tte_erase_screen();
obj_hide(prof);
REG_BG2VOFS = BG2VOF_LARGE_TEXTBOX;
return true;
case CMD_HIDE_LARGE_TEXTBOX:
tte_erase_screen();
obj_unhide(prof, 0);
REG_BG2VOFS = BG2VOF_SMALL_TEXTBOX;
return true;
case CMD_CONTINUE_LINK:
party_data.continue_link();
return true;
case CMD_BOX_MENU:
party_data.fill_simple_pkmn_array();
box_viewer.box_main(party_data);
return true;
default:
tte_set_pos(0, 0);

View File

@ -1,5 +1,3 @@
// This file is a MESS and needs to be made way more clean.
#include <tonc.h>
#include <cstring>
#include "sprite_data.h"
@ -9,6 +7,28 @@
OBJ_ATTR obj_buffer[128];
OBJ_AFFINE *obj_aff_buffer = (OBJ_AFFINE *)obj_buffer;
// These are the two pallets used by the menu sprites,
// it's easier to set them up this way instead of through grit
// (R + G*32 + B*1024)
#define WHITE (31 + 31*32 + 31*1024)
#define YELLOW (31 + 19*32 + 10*1024)
#define RED (31 + 07*32 + 04*1024)
#define BLACK (00 + 00*32 + 00*1024)
const unsigned short frame_one_pal[16] = {
WHITE, WHITE, WHITE, WHITE,
YELLOW, YELLOW, YELLOW, YELLOW,
RED, RED, RED, RED,
BLACK, BLACK, BLACK, BLACK
};
const unsigned short frame_two_pal[16] = {
WHITE, YELLOW, RED, BLACK,
WHITE, YELLOW, RED, BLACK,
WHITE, YELLOW, RED, BLACK,
WHITE, YELLOW, RED, BLACK,
};
// BACKGROUNDS
#include "background.h"
@ -101,6 +121,17 @@ OBJ_ATTR *button_gold_silver_right = &obj_buffer[num_sprites++];
OBJ_ATTR *button_crystal_left = &obj_buffer[num_sprites++];
OBJ_ATTR *button_crystal_right = &obj_buffer[num_sprites++];
OBJ_ATTR *box_select = &obj_buffer[num_sprites++];
OBJ_ATTR *party_sprites[30] = {
&obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++],
&obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++],
&obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++],
&obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++],
&obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++],
&obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++], &obj_buffer[num_sprites++],
};
u32 global_tile_id_end = 0;
void load_eternal_sprites()
@ -138,7 +169,6 @@ void load_temp_sprites(int sprite_batch_id)
}
break;
case SPRITE_BATCH_LANG:
load_sprite(btn_lang_jpn, btn_lang_jpnTiles, btn_lang_jpnTilesLen, curr_tile_id, BTN_PAL, ATTR0_WIDE, ATTR1_SIZE_64x32, 1);
load_sprite(btn_lang_eng, btn_lang_engTiles, btn_lang_engTilesLen, curr_tile_id, BTN_PAL, ATTR0_WIDE, ATTR1_SIZE_64x32, 1);
load_sprite(btn_lang_fre, btn_lang_freTiles, btn_lang_freTilesLen, curr_tile_id, BTN_PAL, ATTR0_WIDE, ATTR1_SIZE_64x32, 1);
@ -149,7 +179,6 @@ void load_temp_sprites(int sprite_batch_id)
break;
case SPRITE_BATCH_GAMES:
load_sprite(button_red_green_left, button_red_green_leftTiles, button_red_green_leftTilesLen, curr_tile_id, BTN_PAL, ATTR0_WIDE, ATTR1_SIZE_64x32, 1);
load_sprite(button_red_green_right, button_game_select_edgeTiles, button_game_select_edgeTilesLen, curr_tile_id, BTN_PAL, ATTR0_TALL, ATTR1_SIZE_8x32, 1);
load_sprite(button_blue_left, button_blue_leftTiles, button_blue_leftTilesLen, curr_tile_id, BTN_PAL, ATTR0_WIDE, ATTR1_SIZE_64x32, 1);
@ -166,6 +195,19 @@ void load_temp_sprites(int sprite_batch_id)
}
}
void load_temp_box_sprites(Pokemon_Party party_data){
u32 curr_tile_id = global_tile_id_end;
for (int i = 0; i < 30; i++){
if (party_data.get_simple_pkmn(i).is_valid){
load_sprite(party_sprites[i], &duel_frame_menu_spritesTiles[(MENU_SPRITES[party_data.get_simple_pkmn(i).dex_number] - 1) * 32], 256, curr_tile_id, MENU_SPRITE_PAL, ATTR0_SQUARE, ATTR1_SIZE_16x16, 2);
obj_set_pos(party_sprites[i], (16 * (i % 10)) + 40, (16 * (i / 10)) + 24);
obj_unhide(party_sprites[i], 0);
}
curr_tile_id += 4;
}
load_sprite(box_select, box_selectTiles, box_selectTilesLen, curr_tile_id, BTN_PAL, ATTR0_SQUARE, ATTR1_SIZE_16x16, 1);
}
void load_sprite(OBJ_ATTR *sprite, const unsigned int objTiles[], int objTilesLen,
u32 &tile_id, u32 pal_bank, int attr0, int attr1, u32 priority)
{