Added Screen for all open instructions.

Moved all `open` instructions to `OpenScreen`.
This commit is contained in:
Filipe Rodrigues 2021-08-07 19:52:07 +01:00
parent 93efca5ff7
commit 8543f536aa
4 changed files with 48 additions and 34 deletions

View File

@ -5,13 +5,13 @@
//! The first word of the instruction is the mnemonic, with the words following being data.
// Imports
use crate::ComboBox;
use crate::{ComboBox, Screen};
use byteorder::{ByteOrder, LittleEndian};
use std::assert_matches::assert_matches;
/// Instruction
// TODO: Merge common instructions
#[derive(PartialEq, Clone, Debug)]
#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)]
pub enum Inst<'a> {
/// Displays the text buffer in the text box.
///
@ -33,27 +33,13 @@ pub enum Inst<'a> {
/// Sets the background to the battle cafe
SetBgBattleCafe,
/// Opens a screen
OpenScreen(Screen),
/// Sets the background to the battle arena
// TODO: Check what texture it uses, looks all messed up most of the times.
SetBgBattleArena,
/// Opens the player room
OpenPlayerRoom,
/// Opens the card list
OpenCardList,
/// Opens the partner chooser screen
// TODO: Figure out parameters for this, they're all veemon
OpenChoosePartner,
/// Opens the keyboard
// TODO: Check where the text goes
OpenKeyboard,
/// Opens the partner edit screen
OpenEditPartner,
/// Opens the center text box
// TODO: Rename, somewhat confusing
DisplayCenterTextBox,
@ -174,12 +160,12 @@ impl<'a> Inst<'a> {
[0x0a, 0x0, 0x04, 0x0] => Self::DisplayTextBuffer,
[0x0a, 0x0, 0x05, 0x0] => Self::WaitInput,
[0x0a, 0x0, 0x06, 0x0] => Self::EmptyTextBox,
[0x0a, 0x0, 0x07, 0x0] => Self::OpenPlayerRoom,
[0x0a, 0x0, 0x09, 0x0] => Self::OpenCardList,
[0x0a, 0x0, 0x0a, 0x0] => Self::OpenChoosePartner,
[0x0a, 0x0, 0x07, 0x0] => Self::OpenScreen(Screen::PlayerRoom),
[0x0a, 0x0, 0x09, 0x0] => Self::OpenScreen(Screen::CardList),
[0x0a, 0x0, 0x0a, 0x0] => Self::OpenScreen(Screen::ChoosePartner),
[0x0a, 0x0, 0x0c, 0x0] => Self::SetBgBattleArena,
[0x0a, 0x0, 0x0f, 0x0] => Self::OpenKeyboard,
[0x0a, 0x0, 0x11, 0x0] => Self::OpenEditPartner,
[0x0a, 0x0, 0x0f, 0x0] => Self::OpenScreen(Screen::Keyboard),
[0x0a, 0x0, 0x11, 0x0] => Self::OpenScreen(Screen::EditPartner),
[0x0a, 0x0, 0x16, 0x0] => Self::DisplayCenterTextBox,
[0x0a, 0x0, value0, value1] => Self::Unknown0a {
value: LittleEndian::read_u16(&[value0, value1]),
@ -324,12 +310,8 @@ impl<'a> Inst<'a> {
Inst::EmptyTextBox => 4,
Inst::ComboBoxAwait => 4,
Inst::SetBgBattleCafe => 4,
Inst::OpenPlayerRoom => 4,
Inst::OpenCardList => 4,
Inst::OpenChoosePartner => 4,
Inst::OpenScreen(_) => 4,
Inst::SetBgBattleArena => 4,
Inst::OpenKeyboard => 4,
Inst::OpenEditPartner => 4,
Inst::DisplayCenterTextBox => 4,
Inst::ChangeVar { .. } => 0xc,
Inst::Test { .. } => 0xc,

View File

@ -61,7 +61,9 @@
// Modules
pub mod inst;
pub mod menu;
pub mod screen;
// Exports
pub use inst::Inst;
pub use menu::{ComboBox, ComboBoxButton};
pub use screen::Screen;

34
dcb-msd/src/screen.rs Normal file
View File

@ -0,0 +1,34 @@
//! Screens
/// Screens
#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)]
pub enum Screen {
/// Player room
PlayerRoom,
/// Card list
CardList,
/// Choose Partner
ChoosePartner,
/// Edit partner
EditPartner,
/// Keyboard
Keyboard,
}
impl Screen {
/// Returns a string representing this screen
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Screen::PlayerRoom => "Player's Room",
Screen::CardList => "Card List",
Screen::ChoosePartner => "Choose Partner",
Screen::EditPartner => "Edit Partner",
Screen::Keyboard => "Keyboard",
}
}
}

View File

@ -297,12 +297,8 @@ impl State {
(State::Start, Inst::WaitInput) => println!("wait_input"),
(State::Start, Inst::EmptyTextBox) => println!("clear_screen"),
(State::Start, Inst::SetBgBattleCafe) => println!("display_battle_cafe"),
(State::Start, Inst::OpenPlayerRoom) => println!("display_player_room"),
(State::Start, Inst::OpenCardList) => println!("display_card_list"),
(State::Start, Inst::OpenChoosePartner) => println!("display_choose_partner"),
(State::Start, Inst::OpenScreen(screen)) => println!("open_screen \"{}\"", screen.as_str().escape_debug()),
(State::Start, Inst::SetBgBattleArena) => println!("display_battle_arena"),
(State::Start, Inst::OpenKeyboard) => println!("display_keyboard"),
(State::Start, Inst::OpenEditPartner) => println!("display_edit_partner"),
(State::Start, Inst::DisplayCenterTextBox) => println!("display_text_box"),
(State::Start, Inst::ChangeVar { var, op, value: value1 }) => {
let value = match values.get(&var) {