From 021b862081d7899abf06108f57fe758e6e62d3ca Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Sun, 19 Apr 2020 23:15:26 -0300 Subject: [PATCH 1/3] add default palette config --- src/character/character.rs | 67 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/src/character/character.rs b/src/character/character.rs index b97da79..2c21b5c 100644 --- a/src/character/character.rs +++ b/src/character/character.rs @@ -5,6 +5,66 @@ use psopacket::PSOPacketData; use crate::{PSOPacketData, PacketParseError}; //use crate::PSOPacketData; +const DEFAULT_PALETTE_CONFIG: [u8; 0xE8] = [ + 0, 0, 0, 0, + 1, 0, 0, 0, + 2, 0, 1, 0, + 2, 1, 1, 0, + 4, 0, 1, 0, + 0, 0, 1, 0, + 0, 0, 1, 0, + 0, 0, 1, 0, + 0, 0, 1, 0, + 0, 0, 1, 0, + 0, 0, 1, 0, + 0, 0, 1, 0, + 0, 0, 1, 0, + 0, 0, 1, 0, + 0, 0, 1, 0, + 1, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0 +]; #[repr(u32)] #[derive(Copy, Clone, Hash, PartialEq, Eq)] @@ -136,7 +196,9 @@ impl Character { impl std::default::Default for Character { fn default() -> Character { - Character::from_bytes(&mut std::io::Cursor::new([0; 0x190].to_vec())).unwrap() + let mut c = Character::from_bytes(&mut std::io::Cursor::new([0; 0x190].to_vec())).unwrap(); + c.config = DEFAULT_PALETTE_CONFIG; + c } } @@ -313,11 +375,10 @@ pub struct FullCharacter { pub section_id: u8, pub char_class: u8, pub _unknown2: u32, - pub symbol_chats: [u8; 1248], + pub symbol_chats: [u8; 0x4E0], pub shortcuts: [u8; 2624], pub autoreply: [u16; 172], pub info_board: [u16; 172], - pub _unknown3: [u8; 28], pub challenge_data: [u8; 320], pub tech_menu: [u8; 40], pub _unknown4: [u8; 44], From b8e420fa7b94a13dd4e84bb00ec5add6004a5eab Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Mon, 20 Apr 2020 00:31:27 -0300 Subject: [PATCH 2/3] add default quick tech menu --- src/character/character.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/character/character.rs b/src/character/character.rs index 2c21b5c..d963813 100644 --- a/src/character/character.rs +++ b/src/character/character.rs @@ -66,6 +66,29 @@ const DEFAULT_PALETTE_CONFIG: [u8; 0xE8] = [ 0, 0, 0, 0 ]; +const DEFAULT_TECH_MENU: [u8; 40] = [ + 0x00, 0x00, + 0x06, 0x00, + 0x03, 0x00, + 0x01, 0x00, + 0x07, 0x00, + 0x04, 0x00, + 0x02, 0x00, + 0x08, 0x00, + 0x05, 0x00, + 0x09, 0x00, + 0x12, 0x00, + 0x0f, 0x00, + 0x10, 0x00, + 0x11, 0x00, + 0x0d, 0x00, + 0x0a, 0x00, + 0x0b, 0x00, + 0x0c, 0x00, + 0x0e, 0x00, + 0x00, 0x00, +]; + #[repr(u32)] #[derive(Copy, Clone, Hash, PartialEq, Eq)] pub enum Class { @@ -388,7 +411,9 @@ pub struct FullCharacter { impl std::default::Default for FullCharacter { fn default() -> FullCharacter { - FullCharacter::from_bytes(&mut std::io::Cursor::new([0; 0x3998].to_vec())).unwrap() + let mut fc = FullCharacter::from_bytes(&mut std::io::Cursor::new([0; 0x3998].to_vec())).unwrap(); + fc.tech_menu = DEFAULT_TECH_MENU; + fc } } From 8b96b0833e157aa2d8c547a1630512bb911ed8eb Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Mon, 20 Apr 2020 00:41:52 -0300 Subject: [PATCH 3/3] pub consts are hard --- src/character/character.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/character/character.rs b/src/character/character.rs index d963813..e2a1b9e 100644 --- a/src/character/character.rs +++ b/src/character/character.rs @@ -5,7 +5,7 @@ use psopacket::PSOPacketData; use crate::{PSOPacketData, PacketParseError}; //use crate::PSOPacketData; -const DEFAULT_PALETTE_CONFIG: [u8; 0xE8] = [ +pub const DEFAULT_PALETTE_CONFIG: [u8; 0xE8] = [ 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 1, 0, @@ -66,7 +66,7 @@ const DEFAULT_PALETTE_CONFIG: [u8; 0xE8] = [ 0, 0, 0, 0 ]; -const DEFAULT_TECH_MENU: [u8; 40] = [ +pub const DEFAULT_TECH_MENU: [u8; 40] = [ 0x00, 0x00, 0x06, 0x00, 0x03, 0x00, @@ -219,9 +219,7 @@ impl Character { impl std::default::Default for Character { fn default() -> Character { - let mut c = Character::from_bytes(&mut std::io::Cursor::new([0; 0x190].to_vec())).unwrap(); - c.config = DEFAULT_PALETTE_CONFIG; - c + Character::from_bytes(&mut std::io::Cursor::new([0; 0x190].to_vec())).unwrap() } } @@ -402,6 +400,7 @@ pub struct FullCharacter { pub shortcuts: [u8; 2624], pub autoreply: [u16; 172], pub info_board: [u16; 172], + pub _unknown3: [u8; 28], pub challenge_data: [u8; 320], pub tech_menu: [u8; 40], pub _unknown4: [u8; 44], @@ -411,9 +410,7 @@ pub struct FullCharacter { impl std::default::Default for FullCharacter { fn default() -> FullCharacter { - let mut fc = FullCharacter::from_bytes(&mut std::io::Cursor::new([0; 0x3998].to_vec())).unwrap(); - fc.tech_menu = DEFAULT_TECH_MENU; - fc + FullCharacter::from_bytes(&mut std::io::Cursor::new([0; 0x3998].to_vec())).unwrap() } }