diff --git a/src/c/battle_data.h b/src/c/battle_data.h new file mode 100644 index 0000000..064d6a8 --- /dev/null +++ b/src/c/battle_data.h @@ -0,0 +1,20 @@ +#ifndef HEADER_BATTLE_DATA_INCLUDED +#define HEADER_BATTLE_DATA_INCLUDED + +#include "types.h" + +// NOTE: WE DON'T KNOW HOW BIG THIS STRUCT IS +typedef struct BATTLE_DATA { + byte unknown[0x42]; + short id; //0x42 + byte unknown_2[0x15]; + byte letter; //0x59 + byte unknown_3[0x2]; + bool is_enemy; //0x5C + byte npc_id; //0x5D + byte pc_id; //0x5E + byte unknown_4[0x33]; + short enemy_id; //0x92 +} BATTLE_DATA; + +#endif \ No newline at end of file diff --git a/src/c/custom_codes.c b/src/c/custom_codes.c index 94cc81b..ec0c80e 100644 --- a/src/c/custom_codes.c +++ b/src/c/custom_codes.c @@ -13,7 +13,7 @@ int custom_codes_parse(int code, char* parserAddress, WINDOW* window) return custom_codes_parse_generic(code, parserAddress, window, (byte*)BASE_GRAPHICS_ADDRESS); } -int load_The_user_target(byte* base_data_ptr) +int load_The_user_target(BATTLE_DATA* bd, bool ignore_letters) { int val_to_store = 1; short user; @@ -21,36 +21,36 @@ int load_The_user_target(byte* base_data_ptr) if(!m2_is_battle) return 1; - if((*(base_data_ptr + BATTLE_USER_INFO_BASE) == 1) || (*(base_data_ptr + BATTLE_USER_INFO_BASE + 1) != 0)) + if(bd->is_enemy || bd->npc_id != 0) { - user = *((short*)(base_data_ptr + BATTLE_USER_DATA_BASE)); + user = m2_btl_target_ptr->id; val_to_store = (m2_enemy_attributes[user] & 0xFF) + 1; - if(user != PORKY && (*(base_data_ptr + BATTLE_USER_INFO_BASE) == 1)) + if(!ignore_letters && user != PORKY && bd->is_enemy) { - if(((*(base_data_ptr + BATTLE_USER_INFO_BASE - 3) != 1) || m2_sub_daf84((*((short*)(base_data_ptr + BATTLE_USER_VAL_BASE)))) != 2)) - val_to_store = 1; //Multiple of the same enemy are on the field... + if(bd->letter != 1 || m2_sub_daf84(bd->enemy_id) != 2) + val_to_store = NO_THE; //Multiple of the same enemy are on the field... } if(user == KING) - val_to_store = 1; + val_to_store = NO_THE; } else - val_to_store = 1; //It's a party member, no "The " + val_to_store = NO_THE; //It's a party member, no "The " return val_to_store; } -int load_gender_user_target(byte* base_data_ptr) +int load_gender_user_target(BATTLE_DATA* bd) { - int val_to_store = 1; + int val_to_store = MALE; //Default is male short user; if(!m2_is_battle) return m2_cstm_last_pc != PAULA ? MALE : FEMALE; //Only Paula is female - if((*(base_data_ptr + BATTLE_USER_INFO_BASE) == 1) || (*(base_data_ptr + BATTLE_USER_INFO_BASE + 1) != 0)) + if(bd->is_enemy || bd->npc_id != 0) { - user = *((short*)(base_data_ptr + BATTLE_USER_DATA_BASE)); + user = m2_btl_target_ptr->id; val_to_store = ((m2_enemy_attributes[user] >> 8) & 0xFF); if(user == KING) @@ -58,9 +58,9 @@ int load_gender_user_target(byte* base_data_ptr) } else { - user = *((short*)(base_data_ptr + BATTLE_USER_DATA_BASE)); + user = bd->id; if(user <= 3) - val_to_store = (*(base_data_ptr + BATTLE_USER_INFO_BASE + 2)) != PAULA ? MALE : FEMALE; //Only Paula is female + val_to_store = bd->pc_id != PAULA ? MALE : FEMALE; //Only Paula is female } return val_to_store; @@ -95,6 +95,7 @@ int custom_codes_parse_generic(int code, char* parserAddress, WINDOW* window, by case STORE_TO_WINDOW_DATA: // 5E FF XX : Load a value into memory, based on XX + addedSize = 3; val_to_store = 0; store = false; switch((byte)parserAddress[2]) @@ -107,13 +108,14 @@ int custom_codes_parse_generic(int code, char* parserAddress, WINDOW* window, by case BATTLE_USER_THE: // 5E FF 02 : Load user's usage of "The " into memory - val_to_store = load_The_user_target(m2_btl_user_ptr); + val_to_store = load_The_user_target(m2_btl_user_ptr, (bool)parserAddress[3]); + addedSize += 1; store = true; break; case BATTLE_TARGET_THE: // 5E FF 03 : Load target's usage of "The " into memory - val_to_store = load_The_user_target(m2_btl_target_ptr); + val_to_store = load_The_user_target(m2_btl_target_ptr, false); store = true; break; @@ -134,7 +136,6 @@ int custom_codes_parse_generic(int code, char* parserAddress, WINDOW* window, by } if(store) m2_store_to_win_memory(val_to_store); - addedSize = 3; break; case CALL_GIVE_TEXT: diff --git a/src/c/custom_codes.h b/src/c/custom_codes.h index 8b4c690..0a8cf3a 100644 --- a/src/c/custom_codes.h +++ b/src/c/custom_codes.h @@ -4,6 +4,7 @@ #include "types.h" #include "locs.h" #include "window.h" +#include "battle_data.h" #define INV_WINDOW_VALUE 4 #define DIALOGUE_WINDOW_VALUE 2 @@ -13,9 +14,8 @@ #define FEMALE 2 #define NEUTRAL 3 -#define BATTLE_USER_DATA_BASE 0x42 -#define BATTLE_USER_INFO_BASE 0x5C -#define BATTLE_USER_VAL_BASE 0x92 +#define NO_THE 1 + #define KING 0xA0 #define PORKY 0xD8 @@ -46,8 +46,8 @@ extern byte m2_sub_daf84(short value); extern unsigned short m2_enemy_attributes[]; extern short m2_is_battle; extern byte m2_cstm_last_pc; -extern byte* m2_btl_user_ptr; -extern byte* m2_btl_target_ptr; +extern BATTLE_DATA* m2_btl_user_ptr; +extern BATTLE_DATA* m2_btl_target_ptr; extern byte m2_bat_enemies_size; extern byte m2_source_pc; extern byte m2_active_window_pc; diff --git a/working/m12-strings-english.txt b/working/m12-strings-english.txt index 7a7f6df..819bcc3 100644 --- a/working/m12-strings-english.txt +++ b/working/m12-strings-english.txt @@ -1186,7 +1186,7 @@ ^L1188^[D4 FF 19 00]@[86 FF _userupperthe_][9F FF] sends[01 FF] a greeting![02 FF][00 FF] ^L1189^[D4 FF 19 00]@[86 FF _userupperthe_][9F FF] is[01 FF] making a loud, piercing howl.[02 FF][00 FF] ^L1190^[D4 FF 19 00]@[86 FF _userupperthe_][9F FF] is[01 FF] saying [02 FF][00 FF] -^L1191^[FC FF 3B 00][82 FF _L3512_][C1 FF][87 FF][E3 FF][9A FF 02 00][81 FF _L3513_][E4 FF][81 FF _L3514_][E5 FF][81 FF _L3515_]@[86 FF _userupperthe_][9F FF] took[01 FF] the [90 FF 00][1A FF 02 00] out and[02 FF]@[86 FF _targetlowerthe_][AD FF] ate it.[D4 FF 44 00][02 FF][00 FF] +^L1191^[FC FF 3B 00][82 FF _L3512_][C1 FF][87 FF][E3 FF][9A FF 02 00][81 FF _L3513_][E4 FF][81 FF _L3514_][E5 FF][81 FF _L3515_]@[86 FF _userupperthe_][9F FF] took[01 FF] the [90 FF 00][1A FF 02 00] out and[02 FF]@[86 FF _targetupperthe_][AD FF] ate it.[D4 FF 44 00][02 FF][00 FF] ^L1192^[FC FF 3B 00][82 FF _L3507_]@[86 FF _userupperthe_][9F FF][C1 FF][87 FF] used the[01 FF] [90 FF 00][1A FF 02 00]![02 FF][00 FF] ^L1193^[FC FF 3B 00][82 FF _L3508_]@[86 FF _userupperthe_][9F FF][C1 FF][87 FF] used the[01 FF] [90 FF 00][1A FF 02 00]![1B FF 1E 00][D4 FF 36 00][1B FF 1E 00][F0 FF 00 00 01 00][1B FF 3C 00][02 FF][00 FF] ^L1194^[FC FF 3B 00][82 FF _L3511_]@[86 FF _userupperthe_][9F FF][C1 FF][87 FF] used the[01 FF] [90 FF 00][1A FF 02 00]![1B FF 1E 00][D4 FF 63 00][F0 FF 00 00 1B 00][1B FF 3C 00][02 FF][00 FF] @@ -1294,7 +1294,7 @@ ^L1296^@(Dear [0D FF],[01 FF] How are you?[02 FF]@Since you left home on your[01 FF] journey, things have changed[01 FF] around here.[02 FF]@For example, I don't have as[01 FF] much laundry.[02 FF]@Also, we don't seem to eat[01 FF] [11 FF] as much as we[01 FF] used to.[02 FF]@I heard that you defeated some[01 FF] universal evil character--what[01 FF] was it,[02 FF]@Googi, or something like that?[02 FF]@Well, that sounds really great![01 FF] I want to hear all the details, so[01 FF] hurry home, okay?[02 FF]@Tracy, [15 FF] and I are[01 FF] waiting for you.[02 FF]@ Love,[01 FF] Mama)[1D FF][00 FF] ^L1297^@(Dear [0F FF],[01 FF] Everything's really going great[01 FF] here.[02 FF]@I wish I could have gone with[01 FF] you on your adventure, even[01 FF] just part of the way,[02 FF]@but instead I'm sitting here,[01 FF] waiting for you in Winters.[02 FF]@I want to see you again as soon[01 FF] as possible. I can't wait to see[01 FF] your cheerful face.[02 FF]@I bet your glasses are dirty... If[01 FF] you come back, I'll clean them[01 FF] for you![02 FF]@Like I said, I'm waiting for you.[02 FF]@ Yours truly,[01 FF] Tony [02 FF][01 FF]@P.S. Don't show this letter to[01 FF] anyone!)[1D FF][00 FF] ^L1298^@(Dear [0E FF],[01 FF] How are you doing?[01 FF] I'm fine.[02 FF]@I fine too![02 FF]@So are me![02 FF]@Me also![02 FF]@Me okay.[02 FF]@Please come and play with us[01 FF] again at the Polestar Preschool.[02 FF]@Oh yeah, one more thing, bring[01 FF] us some presents ...if you have[01 FF] any.[02 FF]@ Sincerely,[01 FF] Your friends at the[01 FF] Polestar Preschool)[1D FF][00 FF] -^L1299^@All of a sudden,[02 FF]@[86 FF _userlowerthe_][9F FF] gave off[01 FF] a rainbow of colors![D4 FF 41 00][F0 FF 28 00 00 00][1B FF 1E 00][D4 FF 41 00][F0 FF 28 00 00 00][1B FF 1E 00][D4 FF 41 00][F0 FF 28 00 00 00][1B FF 1E 00][00 FF] +^L1299^@All of a sudden,[02 FF]@[86 FF _userupperthe_][9F FF] gave off[01 FF] a rainbow of colors![D4 FF 41 00][F0 FF 28 00 00 00][1B FF 1E 00][D4 FF 41 00][F0 FF 28 00 00 00][1B FF 1E 00][D4 FF 41 00][F0 FF 28 00 00 00][1B FF 1E 00][00 FF] ^L1300^[D4 FF 1C 00]@[86 FF _userupperthe_][9F FF] prayed[01 FF] from bottom of her heart![02 FF][1B FF 3C 00][61 FF 02 00]@<...Please give us strength,[22 FF][01 FF]@if it is possible...[01 FF] Please...>[22 FF][01 FF]@<................[01 FF] Somebody... help us...>[61 FF 01 00][1B FF 96 00][00 FF] ^L1301^[D4 FF 1C 00]@[86 FF _userupperthe_][9F FF] prayed[01 FF] from bottom of her heart![02 FF][1B FF 3C 00][61 FF 02 00]@<...Please give us strength![22 FF][01 FF]@Anyone who can hear our plea...[01 FF] Help us...>[61 FF 01 00][1B FF 96 00][00 FF] ^L1302^[D4 FF 1C 00]@[86 FF _userupperthe_][9F FF] prayed[01 FF] from bottom of her heart![02 FF][1B FF 3C 00][61 FF 02 00]@<...Please give us strength![22 FF][01 FF]@Speed this prayer[01 FF] to all the people of the earth.>[61 FF 01 00][1B FF 96 00][00 FF] @@ -1946,16 +1946,16 @@ ^L1951^[83 FF C5 00][82 FF _L2197_][08 FF 0C 02][A2 FF _L5617_][FC FF 05 00][1C FF 80 01 _L2197_][9D FF 01 1F _L5625_][00 FF] ^L1952^[1C FF 49 00 _L2197_][9D FF 01 0E _L5614_][00 FF] ^L10000^[5E FF 01][95 FF 03 _L10001_ _L10002_ _L10003_][00 FF] -^L10001^[86 FF _userupperthe_][9F FF][00 FF] -^L10002^[86 FF _userupperthe_][9F FF] and its cohort[00 FF] -^L10003^[86 FF _userupperthe_][9F FF] and its cohorts[00 FF] +^L10001^[86 FF _useruppertheignore_][9F FF][00 FF] +^L10002^[86 FF _useruppertheignore_][9F FF] and its cohort[00 FF] +^L10003^[86 FF _useruppertheignore_][9F FF] and its cohorts[00 FF] ^L10004^[5E FF 01][95 FF 03 _L10005_ _L10006_ _L10007_][00 FF] -^L10005^[86 FF _userlowerthe_][9F FF][00 FF] -^L10006^[86 FF _userlowerthe_][9F FF][01 FF] and its cohort[00 FF] -^L10007^[86 FF _userlowerthe_][9F FF][01 FF] and its cohorts[00 FF] -^L10008^[5E FF 01][95 FF 03 _L10009_ _L10010_ _L10011_]^L10011^[86 FF _userlowerthe_][9F FF][01 FF] and its cohorts's[00 FF] -^L10009^[86 FF _userlowerthe_][9F FF]'s[01 FF] [00 FF] -^L10010^[86 FF _userlowerthe_][9F FF][01 FF] and its cohort's[00 FF] +^L10005^[86 FF _userlowertheignore_][9F FF][00 FF] +^L10006^[86 FF _userlowertheignore_][9F FF][01 FF] and its cohort[00 FF] +^L10007^[86 FF _userlowertheignore_][9F FF][01 FF] and its cohorts[00 FF] +^L10008^[5E FF 01][95 FF 03 _L10009_ _L10010_ _L10011_]^L10011^[86 FF _userlowertheignore_][9F FF][01 FF] and its cohorts's[00 FF] +^L10009^[86 FF _userlowertheignore_][9F FF]'s[01 FF] [00 FF] +^L10010^[86 FF _userlowertheignore_][9F FF][01 FF] and its cohort's[00 FF] ^L1953^@[86 FF _L10000_][01 FF] attacked![02 FF][00 FF] ^L1954^@[86 FF _L10000_] trapped you![02 FF][00 FF] ^L1955^@[86 FF _targetupperthe_][AD FF] turned[01 FF] back to normal![D4 FF 21 00][00 FF] @@ -3195,15 +3195,15 @@ ^L3509^@[86 FF _userupperthe_][9F FF] used the[01 FF][C1 FF][87 FF] [90 FF 00][1A FF 02 00]![1B FF 1E 00][D4 FF 3B 00][F0 FF 00 00 04 00][1B FF 3C 00][02 FF][00 FF] ^L3510^@[86 FF _userupperthe_][9F FF][C1 FF][87 FF] used the[01 FF] [90 FF 00][1A FF 02 00]![1B FF 1E 00][D4 FF 3B 00][F0 FF 00 00 1E 00][1B FF 3C 00][02 FF][00 FF] ^L3511^@[86 FF _userupperthe_][9F FF][C1 FF][87 FF] used the[01 FF] [90 FF 00][1A FF 02 00][1B FF 1E 00][D4 FF 63 00][F0 FF 00 00 1B 00][1B FF 3C 00][02 FF][00 FF] -^L3512^[C1 FF][87 FF][E3 FF][9A FF 02 00][81 FF _L3521_][E4 FF][81 FF _L3522_][E5 FF][81 FF _L3523_]@[86 FF _userupperthe_][9F FF] took[01 FF] the [90 FF 00][1A FF 02 00] out and[02 FF]@[86 FF _targetlowerthe_][AD FF] ate it.[D4 FF 44 00][02 FF][00 FF] +^L3512^[C1 FF][87 FF][E3 FF][9A FF 02 00][81 FF _L3521_][E4 FF][81 FF _L3522_][E5 FF][81 FF _L3523_]@[86 FF _userupperthe_][9F FF] took[01 FF] the [90 FF 00][1A FF 02 00] out and[02 FF]@[86 FF _targetupperthe_][AD FF] ate it.[D4 FF 44 00][02 FF][00 FF] ^L3513^[E5 FF][81 FF _L3517_]@[86 FF _userupperthe_][9F FF][C1 FF][87 FF] took[01 FF] the [90 FF 00][1A FF 02 00][02 FF]@and [86 FF _targetlowerthe_][AD FF] drank it.[D4 FF 44 00][1B FF 01 00][02 FF][00 FF] -^L3514^[87 FF][88 FF][E5 FF][81 FF _L3516_][88 FF]@[86 FF _userupperthe_][9F FF] took[01 FF] the [90 FF 00][1A FF 02 00],[02 FF][C1 FF][87 FF] used it on[01 FF] [90 FF 00][1A FF 02 00] and[02 FF]@[86 FF _targetlowerthe_][AD FF] ate it.[D4 FF 44 00][1B FF 01 00][02 FF][00 FF] +^L3514^[87 FF][88 FF][E5 FF][81 FF _L3516_][88 FF]@[86 FF _userupperthe_][9F FF] took[01 FF] the [90 FF 00][1A FF 02 00],[02 FF][C1 FF][87 FF] used it on[01 FF] [90 FF 00][1A FF 02 00] and[02 FF]@[86 FF _targetupperthe_][AD FF] ate it.[D4 FF 44 00][1B FF 01 00][02 FF][00 FF] ^L3515^@[86 FF _userupperthe_][9F FF][C1 FF][87 FF] ate[01 FF] the [90 FF 00][1A FF 02 00].[D4 FF 44 00][02 FF][1B FF 01 00][00 FF] ^L3516^@[86 FF _userupperthe_][9F FF] took[01 FF] the [90 FF 00][1A FF 02 00][02 FF][C1 FF][87 FF]@and used it on[01 FF] the [90 FF 00][1A FF 02 00].[D4 FF 44 00][1B FF 01 00][02 FF][00 FF] ^L3517^@[86 FF _userupperthe_][9F FF][C1 FF][87 FF] drank[01 FF] the [90 FF 00][1A FF 02 00].[D4 FF 44 00][1B FF 01 00][02 FF][00 FF] ^L3518^@[86 FF _L11000_][C1 FF][87 FF] ate[01 FF] the [90 FF 00][1A FF 02 00] together.[D4 FF 44 00][1B FF 01 00][02 FF][00 FF] ^L3521^[E5 FF][81 FF _L3525_]@[86 FF _userupperthe_][9F FF][C1 FF][87 FF] took[01 FF] the [90 FF 00][1A FF 02 00][02 FF]@and [86 FF _targetlowerthe_][AD FF] drank it.[D4 FF 44 00][1B FF 01 00][02 FF][00 FF] -^L3522^[87 FF][88 FF][E5 FF][81 FF _L3524_][88 FF]@[86 FF _userupperthe_][9F FF] took[01 FF] the [90 FF 00][1A FF 02 00],[02 FF][C1 FF][87 FF] used it on[01 FF] [90 FF 00][1A FF 02 00] and[02 FF]@[86 FF _targetlowerthe_][AD FF] ate it.[D4 FF 44 00][1B FF 01 00][02 FF][00 FF] +^L3522^[87 FF][88 FF][E5 FF][81 FF _L3524_][88 FF]@[86 FF _userupperthe_][9F FF] took[01 FF] the [90 FF 00][1A FF 02 00],[02 FF][C1 FF][87 FF] used it on[01 FF] [90 FF 00][1A FF 02 00] and[02 FF]@[86 FF _targetupperthe_][AD FF] ate it.[D4 FF 44 00][1B FF 01 00][02 FF][00 FF] ^L3523^@[86 FF _userupperthe_][9F FF][C1 FF][87 FF] ate[01 FF] the [90 FF 00][1A FF 02 00].[D4 FF 44 00][02 FF][1B FF 01 00][00 FF] ^L3524^@[86 FF _userupperthe_][9F FF] took[01 FF] the [90 FF 00][1A FF 02 00][02 FF][C1 FF][87 FF]@and used it on[01 FF] the [90 FF 00][1A FF 02 00].[D4 FF 44 00][1B FF 01 00][02 FF][00 FF] ^L3525^@[86 FF _userupperthe_][9F FF][C1 FF][87 FF] drank[01 FF] the [90 FF 00][1A FF 02 00].[D4 FF 44 00][1B FF 01 00][02 FF][00 FF] @@ -5207,9 +5207,11 @@ ^L5860^[1C FF BA 00 _L5847_][1C FF 3A 00 _L5846_][1C FF 5B 00 _L5845_][1C FF 8C 00 _L5844_]^L5843^@At the Dinosaur Museum in[01 FF] Fourside...[02 FF]@A man called called Mr. Spoon[01 FF] has a heavy mustache...[86 FF _L5856_][00 FF] ^L5861^[F6 FF 01 00][00 FF] ^L5862^ my dear.[1D FF][00 FF] -^userlowerthe^[5E FF 02][95 FF 02 _none_ _lowerthe_]^none^[00 FF] +^userlowerthe^[5E FF 02][00][95 FF 02 _none_ _lowerthe_]^none^[00 FF] +^userlowertheignore^[5E FF 02][01][95 FF 02 _none_ _lowerthe_][00 FF] ^lowerthe^the [00 FF] -^userupperthe^[5E FF 02][95 FF 02 _none_ _upperthe_][00 FF] +^userupperthe^[5E FF 02][00][95 FF 02 _none_ _upperthe_][00 FF] +^useruppertheignore^[5E FF 02][01][95 FF 02 _none_ _upperthe_][00 FF] ^upperthe^The [00 FF] ^targetlowerthe^[5E FF 03][95 FF 02 _none_ _lowerthe_][00 FF] ^targetupperthe^[5E FF 03][95 FF 02 _none_ _upperthe_][00 FF]