diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-10-01 10:59:09 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2018-10-01 10:59:09 +0800 |
commit | bc58f791a33784ffa25e6aa105ced8245fb91ac7 (patch) | |
tree | 338a17196102d1afa584d7629dd0a483590b6eb9 | |
parent | be9144f843df829fd2529c7ebf518749856eab90 (diff) | |
download | rich4-bc58f791a33784ffa25e6aa105ced8245fb91ac7.tar.xz |
move cards table to 0x0047fdf2
-rw-r--r-- | csrc/card.h | 14 | ||||
-rw-r--r-- | csrc/cards.c | 40 | ||||
-rw-r--r-- | csrc/cards_ui.c | 55 | ||||
-rw-r--r-- | csrc/game_init.c | 2 |
4 files changed, 57 insertions, 54 deletions
diff --git a/csrc/card.h b/csrc/card.h new file mode 100644 index 0000000..b1a086e --- /dev/null +++ b/csrc/card.h @@ -0,0 +1,14 @@ +#include <stdint.h> + +typedef struct +{ + const char *name_ptr; + uint8_t init_amount; + uint8_t price; + uint8_t f6; + uint8_t f7; +} rich4_card; +extern rich4_card cards_table[]; + +typedef int (*card_func)(void); +extern card_func card_functions[]; diff --git a/csrc/cards.c b/csrc/cards.c index 4ed6dc5..d8b868c 100644 --- a/csrc/cards.c +++ b/csrc/cards.c @@ -5,8 +5,40 @@ #include "player_info.h" #include "stock.h" - -typedef int (*card_func)(void); +#include "card.h" + +rich4_card cards_table[] = { + { "\xa7\xa1\xb4\x49\xa5\x64", 1, 200, 2, 2 }, /* 均富卡 */ + { "\xa7\xa1\xb3\x68\xa5\x64", 2, 200, 2, 2 }, /* 均贫卡 */ + { "\xc1\xca\xa6\x61\xa5\x64", 4, 35, 0, 1 }, /* 购地卡 */ + { "\xb4\xab\xa6\x61\xa5\x64", 4, 25, 0, 0 }, /* 换地卡 */ + { "\xb4\xab\xab\xce\xa5\x64", 4, 20, 0, 0 }, /* 换屋卡 */ + { "\xc2\xe0\xa6\x56\xa5\x64", 3, 20, 0, 0 }, /* 转向卡 */ + { "\xa7\xef\xab\xd8\xa5\x64", 8, 15, 0, 0 }, /* 改建卡 */ + { "\xa9\xe7\xbd\xe6\xa5\x64", 3, 20, 0, 1 }, /* 拍卖卡 */ + { "\xa4\xd1\xa8\xcf\xa5\x64", 2, 160, 2, 0 }, /* 天使卡 */ + { "\xb4\x63\xc5\x5d\xa5\x64", 1, 180, 2, 2 }, /* 恶魔卡 */ + { "\xa9\xc7\xc3\x7e\xa5\x64", 2, 60, 0, 2 }, /* 怪兽卡 */ + { "\xa9\xee\xb0\xa3\xa5\x64", 5, 15, 0, 1 }, /* 拆除卡 */ + { "\xb7\x6d\xb9\xdc\xa5\x64", 4, 25, 0, 2 }, /* 抢夺卡 */ + { "\xb0\xb1\xaf\x64\xa5\x64", 4, 20, 0, 0 }, /* 停留卡 */ + { "\xa5\x56\xaf\x76\xa5\x64", 2, 100, 2, 2 }, /* 冬眠卡 */ + { "\xb9\xda\xb9\x43\xa5\x64", 4, 25, 0, 1 }, /* 梦游卡 */ + { "\xb3\xb4\xae\x60\xa5\x64", 4, 20, 0, 2 }, /* 陷害卡 */ + { "\xb4\x5f\xa4\xb3\xa5\x64", 4, 20, 0, 0 }, /* 复仇卡 */ + { "\xb6\xf9\xba\xd7\xa5\x64", 4, 40, 0, 0 }, /* 嫁祸卡 */ + { "\xa7\x4b\xb6\x4f\xa5\x64", 4, 25, 0, 0 }, /* 免费卡 */ + { "\xa7\x4b\xb8\x6f\xa5\x64", 4, 25, 0, 0 }, /* 免罪卡 */ + { "\xb0\x65\xaf\xab\xb2\xc5", 3, 10, 0, 0 }, /* 送神符 */ + { "\xbd\xd0\xaf\xab\xb2\xc5", 3, 20, 0, 0 }, /* 请神符 */ + { "\xac\xf5\xa5\x64", 3, 50, 0, 0 }, /* 红卡 */ + { "\xb6\xc2\xa5\x64", 3, 30, 0, 1 }, /* 黑卡 */ + { "\xac\x64\xb5\x7c\xa5\x64", 4, 35, 0, 1 }, /* 查税卡 */ + { "\xba\xa6\xbb\xf9\xa5\x64", 3, 35, 0, 0 }, /* 涨价卡 */ + { "\xac\x64\xab\xca\xa5\x64", 3, 35, 0, 1 }, /* 查封卡 */ + { "\xa6\x50\xb7\xf9\xa5\x64", 2, 40, 0, 0 }, /* 同盟卡 */ + { "\xaf\x51\xc0\x74\xa5\x64", 3, 70, 0, 0 }, /* 乌龟卡 */ +}; int dummy_func() { @@ -1228,7 +1260,7 @@ int red_card() stocks[sel].f7 = 0x20; fcn.00429040(sel + 1); strcpy_without_spaces(name, stocks[sel].name_ptr); - sprintf(buf, use_rb_card, name, cards_table[24].name_ptr); + sprintf(buf, use_rb_card, name, cards_table[23].name_ptr); fcn.00440cac(buf, 1500); consume_a_card(current_player, 24); return 1; @@ -1269,7 +1301,7 @@ int black_card() stocks[sel].f7 = 2; fcn.00429040(sel + 1); strcpy_without_spaces(name, stocks[sel].name_ptr); - sprintf(buf, use_rb_card, name, cards_table[25].name_ptr); + sprintf(buf, use_rb_card, name, cards_table[24].name_ptr); fcn.00440cac(buf, 1500); sel++; } diff --git a/csrc/cards_ui.c b/csrc/cards_ui.c index d284f10..12028bb 100644 --- a/csrc/cards_ui.c +++ b/csrc/cards_ui.c @@ -12,49 +12,6 @@ uint8_t player_cards[60]; // 0x499120 int selected_card; // 0x48c544 const char str_use[] = "\xa8\xcf\xa5\xce%s"; // 使用%s -typedef struct -{ - const char *name_ptr; - uint8_t init_amount; - uint8_t price; - uint8_t f6; - uint8_t f7; -} rich4_card; - -rich4_card cards_table[] = { - { NULL, 0, 0, 0, 0 }, - { "\xa7\xa1\xb4\x49\xa5\x64", 1, 200, 2, 2 }, /* 均富卡 */ - { "\xa7\xa1\xb3\x68\xa5\x64", 2, 200, 2, 2 }, /* 均贫卡 */ - { "\xc1\xca\xa6\x61\xa5\x64", 4, 35, 0, 1 }, /* 购地卡 */ - { "\xb4\xab\xa6\x61\xa5\x64", 4, 25, 0, 0 }, /* 换地卡 */ - { "\xb4\xab\xab\xce\xa5\x64", 4, 20, 0, 0 }, /* 换屋卡 */ - { "\xc2\xe0\xa6\x56\xa5\x64", 3, 20, 0, 0 }, /* 转向卡 */ - { "\xa7\xef\xab\xd8\xa5\x64", 8, 15, 0, 0 }, /* 改建卡 */ - { "\xa9\xe7\xbd\xe6\xa5\x64", 3, 20, 0, 1 }, /* 拍卖卡 */ - { "\xa4\xd1\xa8\xcf\xa5\x64", 2, 160, 2, 0 }, /* 天使卡 */ - { "\xb4\x63\xc5\x5d\xa5\x64", 1, 180, 2, 2 }, /* 恶魔卡 */ - { "\xa9\xc7\xc3\x7e\xa5\x64", 2, 60, 0, 2 }, /* 怪兽卡 */ - { "\xa9\xee\xb0\xa3\xa5\x64", 5, 15, 0, 1 }, /* 拆除卡 */ - { "\xb7\x6d\xb9\xdc\xa5\x64", 4, 25, 0, 2 }, /* 抢夺卡 */ - { "\xb0\xb1\xaf\x64\xa5\x64", 4, 20, 0, 0 }, /* 停留卡 */ - { "\xa5\x56\xaf\x76\xa5\x64", 2, 100, 2, 2 }, /* 冬眠卡 */ - { "\xb9\xda\xb9\x43\xa5\x64", 4, 25, 0, 1 }, /* 梦游卡 */ - { "\xb3\xb4\xae\x60\xa5\x64", 4, 20, 0, 2 }, /* 陷害卡 */ - { "\xb4\x5f\xa4\xb3\xa5\x64", 4, 20, 0, 0 }, /* 复仇卡 */ - { "\xb6\xf9\xba\xd7\xa5\x64", 4, 40, 0, 0 }, /* 嫁祸卡 */ - { "\xa7\x4b\xb6\x4f\xa5\x64", 4, 25, 0, 0 }, /* 免费卡 */ - { "\xa7\x4b\xb8\x6f\xa5\x64", 4, 25, 0, 0 }, /* 免罪卡 */ - { "\xb0\x65\xaf\xab\xb2\xc5", 3, 10, 0, 0 }, /* 送神符 */ - { "\xbd\xd0\xaf\xab\xb2\xc5", 3, 20, 0, 0 }, /* 请神符 */ - { "\xac\xf5\xa5\x64", 3, 50, 0, 0 }, /* 红卡 */ - { "\xb6\xc2\xa5\x64", 3, 30, 0, 1 }, /* 黑卡 */ - { "\xac\x64\xb5\x7c\xa5\x64", 4, 35, 0, 1 }, /* 查税卡 */ - { "\xba\xa6\xbb\xf9\xa5\x64", 3, 35, 0, 0 }, /* 涨价卡 */ - { "\xac\x64\xab\xca\xa5\x64", 3, 35, 0, 1 }, /* 查封卡 */ - { "\xa6\x50\xb7\xf9\xa5\x64", 2, 40, 0, 0 }, /* 同盟卡 */ - { "\xaf\x51\xc0\x74\xa5\x64", 3, 70, 0, 0 }, /* 乌龟卡 */ -}; - sound_struct snd0 = {1, NULL}; // 0x00482322 sound_struct snd1 = {3, NULL}; // 0x0048233a sound_struct snd2; // 0x0048cae0 @@ -174,13 +131,13 @@ void cards_ui() IDirectDrawSurface_Lock(pddrawsf2, NULL, &sfdesc1, 1, 0); fcn_004563f5(sfdesc1.lpSurface, edi+12, 14, 130); IDirectDrawSurface_Unlock(pddrawsf2, NULL); - ebx = register_wait_callback(cardProc, 0); + int cardid = register_wait_callback(cardProc, 0); fcn_00451edb(ebp, 0, 0x8028); if (ebx != 0) { - edx = cards_table[ebx].name_ptr; /* cards_table has 8 bytes per item */ + edx = cards_table[cardid - 1].name_ptr; sprintf(s, str_use, edx); - fcn_00441f73(ebx, s); - esi = eax = call[0x475d5c+ebx*4]; + fcn_00441f73(cardid, s); + esi = eax = card_functions[cardid](); if (eax) { fcn_4542ce(&snd1, eax); } @@ -221,12 +178,12 @@ void cards_ui() continue; eax = mem[ebx]; - ecx = cards_table[eax].name_ptr; + ecx = cards_table[eax - 1].name_ptr; sprintf(s, str_use, ecx); eax = mem[ebx]; fcn_00441f73(eax, s); eax = mem[ebx]; - call dword [eax*4 + 0x475d5c]; + card_functions[eax](); return; } } diff --git a/csrc/game_init.c b/csrc/game_init.c index a160be7..5c09c05 100644 --- a/csrc/game_init.c +++ b/csrc/game_init.c @@ -139,7 +139,7 @@ int init_new_game(int a0) memset(player_cards, 0, 60); memset(tool_amount, 0, 60); for (int i = 0; i < 30; i++) { - card_amount[i] = cards_table[i+1].init_amount; + card_amount[i] = cards_table[i].init_amount; } for (ebx = 0; ebx < 8; ebx++) { al = byte [ebx*8 + 0x47fee6]; |