Skip to content

Commit

Permalink
Correct bytecode for most of the offset searches
Browse files Browse the repository at this point in the history
  • Loading branch information
asimon-1 committed Feb 16, 2024
1 parent 6862c23 commit c4bcebb
Showing 1 changed file with 24 additions and 41 deletions.
65 changes: 24 additions & 41 deletions src/common/offsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ macro_rules! impl_offset {
// Recommended to use the first 8 instructions (32 bytes), unless the function is shorter

// OFFSET_GET_BATTLE_OBJECT_FROM_ID = 0x3ac540
// TODO: This is wrong, its giving same offset as SET_CPU_CONTROLS 0x2da180
static NEEDLE_GET_BATTLE_OBJECT_FROM_ID: &[u8] = &[
0xff, 0x03, 0x06, 0xd1,
0xee, 0x73, 0x00, 0xfd,
Expand All @@ -75,6 +76,8 @@ static NEEDLE_COPY_SETUP: &[u8] = &[
0xf4, 0x4f, 0x05, 0xa9,
0xfd, 0x7b, 0x06, 0xa9,
0xfd, 0x83, 0x01, 0x91,
0xff, 0x43, 0x17, 0xd1,
0x18, 0xa4, 0x40, 0xf9,
];
impl_offset!(COPY_SETUP);

Expand Down Expand Up @@ -104,7 +107,7 @@ static NEEDLE_SET_CPU_CONTROLS: &[u8] = &[
];
impl_offset!(SET_CPU_CONTROLS);

// OFFSET_ADD_DAMAGE = 0x3ff9a0
// OFFSET_ADD_DAMAGE = 0x3ff9c0
static NEEDLE_ADD_DAMAGE: &[u8] = &[
0x08, 0x20, 0x20, 0x1e,
0x8d, 0x00, 0x00, 0x54,
Expand All @@ -114,7 +117,7 @@ static NEEDLE_ADD_DAMAGE: &[u8] = &[
];
impl_offset!(ADD_DAMAGE);

// OFFSET_CHANGE_ACTIVE_CAMERA = 0x4ee460
// OFFSET_CHANGE_ACTIVE_CAMERA = 0x4ee480
static NEEDLE_CHANGE_ACTIVE_CAMERA: &[u8] = &[
0xff, 0x03, 0x02, 0xd1,
0xf8, 0x5f, 0x04, 0xa9,
Expand All @@ -127,17 +130,12 @@ static NEEDLE_CHANGE_ACTIVE_CAMERA: &[u8] = &[
];
impl_offset!(CHANGE_ACTIVE_CAMERA);

// OFFSET_SET_TRAINING_FIXED_CAMERA_VALUES = 0x3157bb0
// OFFSET_SET_TRAINING_FIXED_CAMERA_VALUES = 0x3158830
static NEEDLE_SET_TRAINING_FIXED_CAMERA_VALUES: &[u8] = &[
0x01, 0xe4, 0x00, 0x2f,
0x20, 0x00, 0xc0, 0x3d,
0x22, 0x1c, 0xa1, 0x4e,
0x02, 0x44, 0x04, 0x6e,
0xe8, 0x0a, 0x01, 0xf0,
0x08, 0x81, 0x47, 0xf9,
0x08, 0x01, 0x40, 0xf9,
0x40, 0x04, 0x18, 0x6e,
0x00, 0xf5, 0x82, 0x3d,
];
impl_offset!(SET_TRAINING_FIXED_CAMERA_VALUES);

Expand All @@ -154,7 +152,7 @@ static NEEDLE_DRAW: &[u8] = &[
];
impl_offset!(DRAW);

// OFFSET_CLOUD_ADD_LIMIT = 0x8dc140
// OFFSET_CLOUD_ADD_LIMIT = 0x8dc160
static NEEDLE_CLOUD_ADD_LIMIT: &[u8] = &[
0xff, 0x03, 0x03, 0xd1,
0xe9, 0x23, 0x05, 0x6d,
Expand All @@ -174,32 +172,27 @@ impl_offset!(CLOUD_ADD_LIMIT);
// IMPORTANT! Because this offset is so close to OFFSET_STALE and
// because we are modifying inline instead of hooking the whole function,
// this hook has to be initialized first! Otherwise the search will fail.
// OFFSET_STALE_MENU = 0x13e88a0
// OFFSET_STALE_MENU = 0x13e88c0
static NEEDLE_STALE_MENU: &[u8] = &[
0xdf, 0x82, 0x2d, 0x39,
0x93, 0x40, 0x8e, 0x94,
0xab, 0x43, 0x8e, 0x94,
0x00, 0x1d, 0xa8, 0x4e,
0xc0, 0xa2, 0x06, 0x91,
0xdf, 0x22, 0x2f, 0x39,
0xff, 0x43, 0x8e, 0x94,
0xca, 0x82, 0x6d, 0x39,
0xe8, 0x77, 0x01, 0x90,
0x08, 0x6d, 0x3c, 0x91,
];
impl_offset!(STALE_MENU);

// IMPORTANT! See above comment for STALE_MENU
// OFFSET_STALE = 0x13e88a4
// OFFSET_STALE = 0x13e88c4
static NEEDLE_STALE: &[u8] = &[
0x93, 0x40, 0x8e, 0x94,
0xab, 0x43, 0x8e, 0x94,
0x00, 0x1d, 0xa8, 0x4e,
0xc0, 0xa2, 0x06, 0x91,
0xdf, 0x22, 0x2f, 0x39,
];
impl_offset!(STALE);

// todo!(Can we remove this and replace with SoundModule::play_se()?)
// OFFSET_PLAY_SE = 0x4cf6a0
// OFFSET_PLAY_SE = 0x4cf6c0
static NEEDLE_PLAY_SE: &[u8] = &[
0xa8, 0x00, 0x00, 0x12,
0x9f, 0x00, 0x00, 0x72,
Expand All @@ -211,7 +204,7 @@ static NEEDLE_PLAY_SE: &[u8] = &[
];
impl_offset!(PLAY_SE);

// OFFSET_CAN_FUTTOBI_BACK = 0x260f950
// OFFSET_CAN_FUTTOBI_BACK = 0x26105d0
static NEEDLE_CAN_FUTTOBI_BACK: &[u8] = &[
0x00, 0x07, 0x00, 0xb4,
0x09, 0x04, 0x40, 0xf9,
Expand All @@ -228,7 +221,7 @@ static NEEDLE_CAN_FUTTOBI_BACK: &[u8] = &[
];
impl_offset!(CAN_FUTTOBI_BACK);

// OFFSET_REUSED_UI = 0x68cd80
// OFFSET_REUSED_UI = 0x68cda0
static NEEDLE_REUSED_UI: &[u8] = &[
0xff, 0x43, 0x01, 0xd1,
0xf5, 0x13, 0x00, 0xf9,
Expand All @@ -242,20 +235,18 @@ static NEEDLE_REUSED_UI: &[u8] = &[
impl_offset!(REUSED_UI);


// OFFSET_OPCF = 0x6b7fdc
// OFFSET_OPCF = 0x6b7ffc
static NEEDLE_OPCF: &[u8] = &[
0x68, 0xb6, 0x40, 0xf9,
0x09, 0x81, 0x49, 0x39,
0x69, 0xe1, 0xff, 0x35,
0x08, 0x55, 0x41, 0x39,
0x28, 0xe1, 0x1f, 0x37,
0xe0, 0x03, 0x13, 0xaa,
0x63, 0x88, 0xf0, 0x97,
0xe9, 0x23, 0x43, 0x6d,
];
impl_offset!(OPCF);

// OFFSET_FIM = 0x17504a0
// OFFSET_FIM = 0x1750f70
static NEEDLE_FIM: &[u8] = &[
0xff, 0x03, 0x02, 0xd1,
0xf7, 0x23, 0x00, 0xf9,
Expand All @@ -268,7 +259,7 @@ static NEEDLE_FIM: &[u8] = &[
];
impl_offset!(FIM);

// OFFSET_SSS_TRAINING = 0x184d1d8
// OFFSET_SSS_TRAINING = 0x184dca8
static NEEDLE_SSS_TRAINING: &[u8] = &[
0x9f, 0xe3, 0x0b, 0x39,
0x88, 0xbf, 0x0b, 0x39,
Expand All @@ -279,7 +270,7 @@ static NEEDLE_SSS_TRAINING: &[u8] = &[
];
impl_offset!(SSS_TRAINING);

// OFFSET_GENERATE_ARTICLE_FOR_TARGET = 0x3d40a0
// OFFSET_GENERATE_ARTICLE_FOR_TARGET = 0x3d40c0
static NEEDLE_GENERATE_ARTICLE_FOR_TARGET: &[u8] = &[
0xf4, 0x4f, 0xbe, 0xa9,
0xfd, 0x7b, 0x01, 0xa9,
Expand All @@ -290,7 +281,7 @@ static NEEDLE_GENERATE_ARTICLE_FOR_TARGET: &[u8] = &[
];
impl_offset!(GENERATE_ARTICLE_FOR_TARGET);

// OFFSET_KIRBY_OPFF = 0xb971b0
// OFFSET_KIRBY_OPFF = 0xb971d0
static NEEDLE_KIRBY_OPFF: &[u8] = &[
0xff, 0x43, 0x02, 0xd1,
0xfc, 0x6f, 0x03, 0xa9,
Expand All @@ -307,7 +298,7 @@ static NEEDLE_KIRBY_OPFF: &[u8] = &[
];
impl_offset!(KIRBY_OPFF);

// OFFSET_ACTIVATE_AUTONOMY = 0x34b5cf0
// OFFSET_ACTIVATE_AUTONOMY = 0x34b6970
static NEEDLE_ACTIVATE_AUTONOMY: &[u8] = &[
0xf6, 0x57, 0xbd, 0xa9,
0xf4, 0x4f, 0x01, 0xa9,
Expand All @@ -320,37 +311,29 @@ static NEEDLE_ACTIVATE_AUTONOMY: &[u8] = &[
];
impl_offset!(ACTIVATE_AUTONOMY);

// OFFSET_POKEMON_DECIDE = 0x34cdc64
// OFFSET_POKEMON_DECIDE = 0x34ce8e4
static NEEDLE_POKEMON_DECIDE: &[u8] = &[
0x28, 0x69, 0x2b, 0x38,
0x48, 0x26, 0x8b, 0x52,
0x2a, 0x69, 0x28, 0x38,
0x88, 0x12, 0x40, 0xf9,
0x49, 0x01, 0x80, 0x52,
0x14, 0x29, 0x40, 0xf9,
0xe9, 0x0b, 0x00, 0xb9,
0x29, 0xdf, 0x00, 0xb0,
];
impl_offset!(POKEMON_DECIDE);

// OFFSET_LAYOUT_ARC_MALLOC = 0x37730d4
// OFFSET_LAYOUT_ARC_MALLOC = 0x3773d54
static NEEDLE_LAYOUT_ARC_MALLOC: &[u8] = &[
0xe3, 0xe6, 0x06, 0x94,
0xa0, 0x05, 0x00, 0xb4,
0xe1, 0x03, 0x15, 0xaa,
0xe2, 0x03, 0x17, 0xaa,
0xc0, 0xb6, 0x00, 0xf9,
0x72, 0x2e, 0x09, 0x94,
0xc1, 0xb6, 0x40, 0xf9,
0xc2, 0x57, 0x00, 0xb0,
];
impl_offset!(LAYOUT_ARC_MALLOC);

// OFFSET_TRAINING_RESET_CHECK = 0x1378e30
// OFFSET_TRAINING_RESET_CHECK = 0x1378e50
static NEEDLE_TRAINING_RESET_CHECK: &[u8] = &[
0x1f, 0x09, 0x00, 0x71,
0x41, 0x1c, 0x00, 0x54,
0xe8, 0xf9, 0x01, 0xf0,
0x08, 0xfa, 0x01, 0xb0,
0x08, 0x7d, 0x42, 0xf9,
0x08, 0x01, 0x40, 0xf9,
0x09, 0xa1, 0x40, 0xb9,
Expand Down

0 comments on commit c4bcebb

Please sign in to comment.