DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
battlemenu.cpp
1#pragma helper_mask_gpr 0x30
2#pragma helper_mask_fpr 0x1000
3#pragma name_counter 2
4#ifdef PAL
5#pragma argument_flag 0
6#pragma argument_flag_ones 58, 65, 66, 144, 209, 238, 377, 387, 414, 419
7#pragma argument_flag_ones 447, 448, 499, 575, 577, 713, 729, 744, 746, 748
8#pragma argument_flag_ones 750
9#pragma argument_flag_ones 752, 753, 763, 765, 766, 792, 803, 816, 818, 827
10#pragma argument_flag_ones 975, 981, 994, 1033, 1054, 1156, 1185, 1325
11#pragma argument_flag_ones 1461, 1463, 1486, 1488, 2014, 2172, 2256, 2267, 2351, 2358
12#pragma argument_flag_ones 2374, 2406, 2407, 2433, 2434, 2441
13#pragma argument_flag_ones 2442, 2471, 2655, 2656, 2725, 2726, 2802, 2803, 2925, 2926
14#pragma argument_flag_ones 2964, 2965, 3099, 3100, 3144, 3156
15#pragma argument_flag_ones 3157, 3164, 3165, 3247, 3587, 3595, 3662, 3663, 3671, 3672
16#pragma argument_flag_ones 3688, 3690, 3696, 3697, 3698, 3730
17#pragma argument_flag_ones 3738, 3739, 3757, 3758, 3784, 3887, 3937, 3939, 4082, 4134
18#pragma argument_flag_ones 4167
19#endif
20
21#include "battlemenu.hpp"
22
23#include <cmath>
24#include <cstdio>
25#include <cstring>
26
27#include "camera.hpp"
28#include "character.hpp"
29#include "clsmes.hpp"
30#include "dataread.hpp"
31#include "dngstatusdata.hpp"
32#include "dun/gameloop.hpp"
33#include "eastking.hpp"
34#include "gamepad.hpp"
35#include "itemdata.hpp"
36#include "mainselect.hpp"
37#include "memcard.hpp"
38#include "menu_draw.hpp"
39#include "menu_dungeon.hpp"
40#include "menu_inventory.hpp"
41#include "menu_manual.hpp"
42#include "menu_misc.hpp"
43#include "menu_save.hpp"
44#include "menuiconautoget.hpp"
45#include "mglib.hpp"
46#include "monstorunit.hpp"
47#include "savedata.hpp"
48#include "shop.hpp"
49#include "snd.hpp"
50#include "texture.hpp"
51#include "weapon_buildup.hpp"
52#include "weaponlevelup.hpp"
53
54static int GetVisitInfo(int place, int menu_mode);
55
56#include <cstdlib>
57
58#include "battle_globals.hpp"
59#include "btactstatus.hpp"
60#include "dataalloc.hpp"
61#include "menuetc.hpp"
62#include "menuitemstep.hpp"
63#include "rect.hpp"
64#include "shot_effect.hpp"
65#include "userstatus.hpp"
66#include "vutext.hpp"
67
68static void DrawStatusNumberNowAndMax(int *values, int x, int y, int color, int alpha);
69static void BattleMenuAppear();
70static int BattleMenuExit();
71static void InitItemTrushStart();
72static int BattleMenuAtoraKey();
73static void BattleMenuOptionKey();
74static void BattleMenuSaveKey();
75static void BattleManualDraw();
76static void InitItemMode(int mode, int chara);
77static void InitMenuChara(u_long128 *buffer);
78static void InitWeaponSelect(int mode, int chara);
79static int WeaponSelectKey();
80static void WeaponMenuActWepKey();
81static void WeaponMenuAttachWepKey();
82static void WeaponMenuAttachKey();
83static int WorldMapMoveKey();
84static void DrawWorldMap(int alpha);
85
86MenuClsMes MenuMes;
87CDataAlloc2<1> MenuExCashBuffer(-1);
88MENU_ICON_POS NorMenuIcon[8];
89float SysCur[3];
90MENU_CHARA_INFO MenuChara;
91CCharacter MenuCharaFrame;
92CCharacter DngWeaponFrm[12];
93WEP_MENU_INFO WepMenu;
94ITEM_MENU_MODE_INFO ItemMenuMode;
95CMenuIconAutoGet IconAutoGet;
96MENU_MOVE_INFO MenuMove;
97
98RECT NumberSprite[2] = {
99 {0, 176, 12, 12},
100 {0, 158, 12, 18}
101};
102
103s16 BtlDrawTbl[2][8] = {
104 {0, 1, 2, 3, 7, 4, 6, 0},
105 {0, 1, 2, 3, 8, 5, 4, 6}
106};
107
108SYS_CHARA_INFO SysChara[6] = {
109 {0, 0, {0, 0}, 0.0f, 0.0f},
110 {1, 0, {0, 0}, 0.0f, 0.0f},
111 {2, 0, {0, 0}, 0.0f, 0.0f},
112 {3, 0, {0, 0}, 0.0f, 0.0f},
113 {4, 0, {0, 0}, 0.0f, 0.0f},
114 {5, 0, {0, 0}, 0.0f, 0.0f},
115};
116
117s16 MenuDefaultWeaponNo[7] = {ITEM_WEAPON_DAGGER_BROKEN, ITEM_WEAPON_WOODENSLINGSHOT_BROKEN, ITEM_WEAPON_MALLET_BROKEN, ITEM_WEAPON_GOLD_RING_BROKEN, ITEM_WEAPON_FIGHTING_STICK_BROKEN, ITEM_WEAPON_MACHINE_GUN_BROKEN, 81};
118
119s16 MenuCharaWeaponMax[6] = {42, 15, 17, 16, 16, 14};
120
121MENU_WEP_POLY_OFFSET MenuWepPolyOffset[6] = {
122 {{0.0f, 0.0f, 0.0f}, 1.0f, {-HALF_PI, 0.0f, 0.62831855f}, {0.0f, 0.028559932f, 0.0f}},
123 {{-0.3f, 0.5f, 0.0f}, 1.4f, {-HALF_PI, 0.0f, 0.62831855f}, {0.0f, 0.028559932f, 0.0f}},
124 {{0.0f, 0.0f, 0.0f}, 0.8f, {-HALF_PI, 0.0f, 0.62831855f}, {0.0f, 0.028559932f, 0.0f}},
125 {{-1.4f, 2.1f, 0.0f}, 4.2f, {-HALF_PI, -0.16453463f, 0.62831855f}, {0.0f, 0.028559932f, 0.0f}},
126 {{-0.8f, 0.7f, 0.0f}, 0.7f, {-HALF_PI, -0.8005375f, 0.62831855f}, {0.0f, 0.028559932f, 0.0f}},
127 {{-0.4f, 0.5f, 0.0f}, 1.0f, {-HALF_PI, 0.0f, 0.62831855f}, {0.0f, 0.028559932f, 0.0f}},
128};
129
130GRADATION_COLOR_INFO2 MenuColorInfo2[26] = {
131 {{{0xF5, 0xAB, 0x48, 0x80}, {0x8C, 0x8E, 0x64, 0x80}, {0x57, 0x59, 0x20, 0x80}, {0x1F, 0x2E, 0x2A, 0x80}}},
132 {{{0x7D, 0xB2, 0xFF, 0x80}, {0x73, 0xA1, 0xC6, 0x80}, {0x2E, 0x5B, 0x78, 0x80}, {0x2D, 0x4C, 0x57, 0x80}}},
133 {{{0x69, 0x9E, 0xF7, 0x80}, {0x5F, 0x8D, 0xB2, 0x80}, {0x24, 0x51, 0x6E, 0x80}, {0x0F, 0x2E, 0x39, 0x80}}},
134 {{{0x1D, 0xF7, 0xA1, 0x80}, {0x61, 0xBA, 0x9D, 0x80}, {0x0A, 0x7B, 0x0A, 0x80}, {0x10, 0x44, 0x2F, 0x80}}},
135 {{{0xFE, 0xC4, 0x00, 0x80}, {0x99, 0xA9, 0x63, 0x80}, {0x55, 0x62, 0x00, 0x80}, {0x22, 0x3C, 0x16, 0x80}}},
136 {{{0x21, 0xBF, 0xFD, 0x80}, {0x40, 0xBA, 0xB4, 0x80}, {0x0B, 0x5F, 0x6E, 0x80}, {0x05, 0x44, 0x38, 0x80}}},
137 {{{0xDD, 0x96, 0xFD, 0x80}, {0x91, 0x95, 0xB1, 0x80}, {0x46, 0x4B, 0x6E, 0x80}, {0x1F, 0x32, 0x37, 0x80}}},
138 {{{0xED, 0x00, 0x00, 0x80}, {0x98, 0x6F, 0x64, 0x80}, {0x65, 0x00, 0x00, 0x80}, {0x37, 0x2C, 0x24, 0x80}}},
139 {{{0x1F, 0x2E, 0xF1, 0x80}, {0x54, 0x94, 0xC9, 0x80}, {0x0D, 0x1B, 0x7D, 0x80}, {0x1A, 0x42, 0x58, 0x80}}},
140 {{{0xEE, 0xBE, 0x00, 0x80}, {0xB3, 0xD7, 0x62, 0x80}, {0x65, 0x6E, 0x00, 0x80}, {0x42, 0x69, 0x23, 0x80}}},
141 {{{0x0F, 0x95, 0x00, 0x80}, {0x4D, 0xD7, 0x65, 0x80}, {0x06, 0x57, 0x00, 0x80}, {0x17, 0x69, 0x24, 0x80}}},
142 {{{0xEE, 0x15, 0xF1, 0x80}, {0xAB, 0x91, 0xB9, 0x80}, {0x65, 0x0C, 0x7D, 0x80}, {0x3E, 0x40, 0x50, 0x80}}},
143 {{{0x38, 0xC3, 0x0B, 0x80}, {0x59, 0xC4, 0x6D, 0x80}, {0x15, 0x66, 0x00, 0x80}, {0x1B, 0x55, 0x2A, 0x80}}},
144 {{{0x77, 0x56, 0xE5, 0x80}, {0x6F, 0x94, 0xA1, 0x80}, {0x2C, 0x2B, 0x6E, 0x80}, {0x22, 0x3D, 0x3E, 0x80}}},
145 {{{0x52, 0xC2, 0xED, 0x80}, {0x62, 0xC3, 0xA7, 0x80}, {0x1F, 0x66, 0x71, 0x80}, {0x1E, 0x55, 0x40, 0x80}}},
146 {{{0xB0, 0x7D, 0x0C, 0x80}, {0x82, 0x97, 0x6A, 0x80}, {0x41, 0x41, 0x02, 0x80}, {0x29, 0x3E, 0x24, 0x80}}},
147 {{{0x8C, 0xEE, 0x08, 0x80}, {0x76, 0xA8, 0x69, 0x80}, {0x34, 0x85, 0x00, 0x80}, {0x25, 0x47, 0x24, 0x80}}},
148 {{{0xCC, 0x80, 0x07, 0x80}, {0x8C, 0xA2, 0x63, 0x80}, {0x4C, 0x42, 0x00, 0x80}, {0x2D, 0x43, 0x21, 0x80}}},
149 {{{0x24, 0xD4, 0xF3, 0x80}, {0x52, 0x9C, 0xB3, 0x80}, {0x0D, 0x76, 0x73, 0x80}, {0x18, 0x40, 0x45, 0x80}}},
150 {{{0xC0, 0xBC, 0xBC, 0x80}, {0x87, 0xC3, 0xA1, 0x80}, {0x47, 0x62, 0x59, 0x80}, {0x2B, 0x55, 0x1A, 0x80}}},
151 {{{0xCC, 0xB1, 0x04, 0x80}, {0x8C, 0xC3, 0x54, 0x80}, {0x4C, 0x5C, 0x00, 0x80}, {0x2C, 0x55, 0x1A, 0x80}}},
152 {{{0xD4, 0x38, 0xCC, 0x80}, {0x8E, 0x86, 0xA2, 0x80}, {0x4F, 0x1A, 0x61, 0x80}, {0x2D, 0x36, 0x3E, 0x80}}},
153 {{{0x40, 0xC1, 0x82, 0x80}, {0x00, 0x81, 0xFF, 0x80}, {0x40, 0xC1, 0x82, 0x80}, {0x00, 0x81, 0xFF, 0x80}}},
154 {{{0xFF, 0x00, 0xC6, 0x80}, {0x3F, 0x00, 0x31, 0x80}, {0xFF, 0x00, 0xC6, 0x80}, {0x3F, 0x00, 0x31, 0x80}}},
155 {{{0xFF, 0x00, 0x00, 0x80}, {0x3F, 0x00, 0x00, 0x80}, {0xFF, 0x00, 0x00, 0x80}, {0x3F, 0x00, 0x00, 0x80}}},
156 {{{0xFF, 0x80, 0x00, 0x80}, {0xFF, 0x20, 0x00, 0x80}, {0xFF, 0x80, 0x00, 0x80}, {0xFF, 0x20, 0x00, 0x80}}},
157};
158
159#ifdef PAL
160s16 BtlMenuNowLang = 1;
161#else
162s32 BtlMenuNowLang = 1;
163#endif
164s32 BattleMenuFlag = BTLMENU_STATE_APPEAR;
165float chara_r_long = 118.0f;
166s16 TrushMoveMax[3] = {3, 1, 3};
167s32 BtlEffectFlag = BTLEFFECT_NONE;
168
169s32 MenuMapJumpMode;
170CSaveData *BtlMenuSaveDataPt;
171CDngStatusData *BtlMenuStatusPt;
172s32 BtlMenuMode;
173s32 BtlMenuBGMvol;
174s32 BtlMenuReadBlock;
175u_long128 *BtlMenuReadBuf;
176s32 BtlMenuReadEndFlag;
177s32 ItemMenuWeaponIconReadBlock;
178s32 ItemMenuAlreadyReadWepIconTexFlag;
179s32 MenuShadowReadBlock;
180#ifdef PAL
181s32 BtlMenuExtBlock;
182#endif
183s32 BtlMenuExReadBlock;
184s32 BtlMenuExReadFlag;
185s32 MenuExtendReadBlock;
186s32 MenuExTextureReadFlag;
187u_long128 *ItemMenuCharaReadBuf;
188s32 BtlMDSBuildCnt;
189s32 BtlMenuManualReadBlock;
190WEAPON_HAVE *DngWepHavePt;
191CWeaponLevelUp *WepMenuEffectReadBuf;
192CTexture *CharaStatus;
193CTexture *MenuCharaFace;
194CTexture *NonCharaFace;
195CTexture *BtStatus;
196CTexture *WepStatus;
197CTexture *BtlAlpha;
198CTexture *BtlHira;
199CTexture *BtlKata;
200#ifdef PAL
201CTexture *BtlEuro;
202#endif
203float HelpWinHead[2];
204u8 BtlWakuMake2;
205s32 BtlHelpWinAlpha;
206float BtlHelpWinW;
207float BtlHelpWinH;
208s32 MenuSelect[2];
209ITEM_PACK *MenuItemPackPt;
210s16 EscapeDngFlg;
211s16 RoomOutFlag;
212float MenuCharaMove;
213float PosAngle;
214IHAVEITEM *BtlHaveItemPt;
215float WepFrameRate;
216float WeaponPos;
217float WepPolyPos;
218float BtlEffectCt;
219s32 MenuWarningMsgFlag;
220u_long128 *BtlMenuCharaChangeBuf;
221
222int GetDefaultWeaponNo(int character_no) {
223 return MenuDefaultWeaponNo[character_no];
224}
225
226int IsDefaultWeapon(int weapon_no) {
227 int owner = -1;
228 int chara;
229
230 for (chara = 0; chara <= 5; chara++) {
231 int default_weapon_no = GetDefaultWeaponNo(chara);
232
233 if (default_weapon_no == weapon_no || default_weapon_no + 1 == weapon_no) {
234 owner = chara;
235 break;
236 }
237 }
238
239 return owner;
240}
241
242void SetNowEquipWeaponDataForMsg(int item_no, int slot) {
243 ItemMenuMode.message_item_no = item_no;
244 ItemMenuMode.message_slot = slot;
245}
246
247void GetNowEquipWeaponDataForMsg(int &item_no, int &slot) {
248 COM_ITEM_INFO *item_info = GetCommonItemInfo(ItemMenuMode.message_item_no);
249
250 if (item_info != NULL) {
251 item_no = item_info->msg;
252 } else {
253 item_no = 0;
254 }
255
256 slot = ItemMenuMode.message_slot;
257}
258
259GRADATION_COLOR_INFO2 *GetGradationColorInfo2(int index) {
260 return &MenuColorInfo2[index];
261}
262
270static WEAPON_HAVE *GetNowSelectWeapon() {
271 int chara = WepMenu.chara;
272 CDngStatusData *status = BtlMenuStatusPt;
273 WEAPON_HAVE *row = status->chara_weapons[chara];
274 return &row[WepMenu.weapon_slot];
275}
276
285static int EscapeDungeonMode() {
286 int mode = ESCAPE_DNG_PAY;
287
288 if (BtlMenuStatusPt->SearchItemIndexNo(ITEM_ESCAPE_POWDER) >= 0) {
289 mode = ESCAPE_DNG_POWDER;
290 }
291
292 if (NowMonstorUnit->GetMonstorNum() <= 0) {
293 mode = ESCAPE_DNG_FREE;
294 }
295
296 return mode;
297}
298
299void SetEscapeDngFlag(int flag) {
300 EscapeDngFlg = flag;
301}
302
303int GetEscapeDngFlag() {
304 return EscapeDngFlg;
305}
306
307void SetInteriorOutFlag(int flag) {
308 RoomOutFlag = flag;
309}
310
311int GetInteriorOutFlag() {
312 return RoomOutFlag;
313}
314
322static void DrawDngYesNoDialog(int x, int y, int alpha) {
323 CRect_i_ dst(x, y, 0x60, 0x20);
324 CRect_i_ src(0, 0, 0x60, 0x20);
325
326 for (int row = 0; row < 2; row++) {
327 DrawMenu2DSprite(BtStatus, dst, src, alpha);
328 dst.y += 0x1C;
329 src.y += 0x20;
330 }
331}
332
341static int GetMenuModeMax() {
342 int icon_count;
343
344 switch (BtlMenuMode) {
345 case BATTLE_MENU_MODE_DUNGEON:
346 icon_count = 7;
347 break;
348 case BATTLE_MENU_MODE_TOWN:
349 icon_count = 8;
350 break;
351 }
352
353 if (GetGameFlagForManualMenu() == 0) {
354 icon_count--;
355 }
356
357 return icon_count;
358}
359
363static void GetMenuIconPos(int icon, int *position) {
364 int next = icon + 1;
365 int x = next * 16 + 80;
366 int y = icon * 40 + 54;
367
368 if (next > 4) {
369 x -= ((icon - 4) << 5) + 16;
370 }
371
372 position[0] = x;
373 position[1] = y;
374}
375
383static void BtlMenuMekeIconInfo(int *icons, int menu_mode) {
384 int icon_count = GetMenuModeMax();
385
386 for (int i = 0; i < icon_count; i++) {
387 icons[i] = BtlDrawTbl[BtlMenuMode][i];
388 }
389
390 if (BtlMenuMode != BATTLE_MENU_MODE_DUNGEON) {
391 int special_icon;
392
393 switch (NowGetGameFlagForBtlMenu(BtlMenuMode)) {
394 case MENU_MOVE_LOCKED:
395 case MENU_MOVE_FIRST_DUNGEON:
396 special_icon = 9;
397 break;
398 case MENU_MOVE_WORLD_MAP:
399 special_icon = 8;
400 break;
401 case MENU_MOVE_INTERIOR_OUT:
402 special_icon = 0xC;
403 break;
404 }
405
406 icons[4] = special_icon;
407 }
408}
409
418static void DrawBtlMenuBar() {
419 int alpha;
420 int icon_alpha;
421 int i;
422 int x;
423 int menu_flag;
424 int brightness;
425 int selected;
426 int y;
427
428 if (BtlEffectFlag == BTLEFFECT_PAGE_CLOSE || BattleMenuFlag == BTLMENU_STATE_APPEAR) {
429 alpha = 10.0f * BtlEffectCt;
430
431 if (alpha >= 128) {
432 alpha = 128;
433 }
434 }
435
436 if (BtlEffectFlag == BTLEFFECT_PAGE_OPEN || BattleMenuFlag == BTLMENU_STATE_EXIT) {
437 alpha = 128.0f - 10.0f * BtlEffectCt;
438
439 if (alpha < 0) {
440 alpha = 0;
441 }
442 } else {
443 alpha = 128;
444 }
445
446 NowGetGameFlagForBtlMenu(BtlMenuMode);
447 int icon_count = GetMenuModeMax();
448 int icons[8];
449 BtlMenuMekeIconInfo(icons, BtlMenuMode);
450
451 for (i = 0; i < icon_count; i++) {
452 icon_alpha = alpha;
453 brightness = 128;
454
455 if (MenuWarningMsgFlag != 0) {
456 brightness = 64;
457 }
458
459 menu_flag = BattleMenuFlag;
460
461 if (BTLMENU_STATE_MAIN < menu_flag && menu_flag < BTLMENU_STATE_ITEM_OPEN) {
462 icon_alpha = 0;
463 }
464
465 selected = 0;
466 float icon_x = NorMenuIcon[i].x;
467 x = icon_x;
468 float icon_y = NorMenuIcon[i].y;
469 float lowered_y = 2.0f + icon_y;
470 y = 1.0f + lowered_y;
471
472 if (i == MenuSelect[1]) {
473 if ((menu_flag == BTLMENU_STATE_APPEAR || menu_flag == BTLMENU_STATE_EXIT) && menu_flag == BTLMENU_STATE_MOVE_OPEN) {
474 icon_alpha = alpha;
475 }
476
477 selected = 1;
478 x = icon_x - 10.0f;
479 y = 1.0f + (icon_y - 2.0f);
480 icon_alpha = 128;
481 }
482
483 if (icons[i] >= 0) {
484 DrawMainMenuIcon(x, y, icons[i], selected, brightness, icon_alpha);
485 }
486 }
487}
488
489int GetLimmitMsg() {
490 int message;
491
492 switch (BtlMenuStatusPt->res_limit_zone_current) {
493 case RES_LIMIT_ZONE_NONE:
494 message = -1;
495 break;
496 case RES_LIMIT_ZONE_NO_WEAPON_CHANGE:
497 message = 0x19E;
498 break;
499 case RES_LIMIT_ZONE_THIRST:
500 message = 0x19F;
501 break;
502 case RES_LIMIT_ZONE_TOAN:
503 case RES_LIMIT_ZONE_XIAO:
504 case RES_LIMIT_ZONE_GORO:
505 case RES_LIMIT_ZONE_RUBY:
506 case RES_LIMIT_ZONE_UNGAGA:
507 case RES_LIMIT_ZONE_OSMOND:
508 message = 0x1A0;
509 break;
510 }
511
512 return message;
513}
514
515void DrawBattleMain() {
516 int pos[2];
517 int icons[8];
518
519 GetMenuIconPos(MenuSelect[1], pos);
520 int x = pos[0] - 0x2C;
521 int y = pos[1];
522 SysCur[0] += ((float) x - SysCur[0]) / 4.0f;
523 SysCur[1] += ((float) y - SysCur[1]) / 4.0f;
524 GetMenuModeMax();
525 BtlMenuMekeIconInfo(icons, BtlMenuMode);
526 MENU_ICON_INFO *info = GetMenuIconInfo(icons[MenuSelect[1]]);
527 int mes_no = info->help_mes_no;
528
529 if (MenuSelect[1] == 4) {
530 switch (NowGetGameFlagForBtlMenu(BtlMenuMode)) {
531 case MENU_MOVE_DUNGEON_ESCAPE: {
532 s16 escape[3] = {0x1B, 0x1C, 0x0F};
533 mes_no = escape[GetEscapeDngFlag()];
534 break;
535 }
536 case MENU_MOVE_LOCKED:
537 mes_no = 0x1D;
538 break;
539 case MENU_MOVE_FIRST_DUNGEON:
540 mes_no = 0x12;
541 break;
542 case MENU_MOVE_WORLD_MAP:
543 mes_no = 0x11;
544 break;
545 case MENU_MOVE_INTERIOR_OUT:
546 mes_no = 0x13;
547 break;
548 }
549 }
550
551 if (CommonMenuMes2.mes_made != mes_no) {
552 CommonMenuMes2.MakeMesWin(mes_no);
553 }
554
555 if (BtlMenuMode == BATTLE_MENU_MODE_DUNGEON) {
556 int limit = GetLimmitMsg();
557
558 if (CommonMenuMes1.mes_made != limit) {
559 CommonMenuMes1.MakeMesWin(limit);
560 }
561
562 if (limit >= 0) {
563 MenuTextureReload(CommonMenuMes1.tex_block);
564
565 if (BtlMenuNowLang > LANG_JAPANESE) {
566 CommonMenuMes1.text_x = 0x44;
567#ifdef PAL
568 CommonMenuMes1.text_y = 0x176;
569#else
570 CommonMenuMes1.text_y = 0x156;
571#endif
572 } else {
573 CommonMenuMes1.text_x = 0x50;
574#ifdef PAL
575 CommonMenuMes1.text_y = 0x16A;
576#else
577 CommonMenuMes1.text_y = 0x14A;
578#endif
579 }
580
581 CommonMenuMes1.stay_frame = true;
582 CommonMenuMes1.Step();
583 CommonMenuMes1.DrawMesWin();
584 }
585 }
586
587 int width = info->label_width + 0x4A;
588 float waku_y = NorMenuIcon[MenuSelect[1]].y - 8.0f;
589 DrawMenuWaku(NorMenuIcon[MenuSelect[1]].x - 18.0f, waku_y, width, 0x22, 0, StayTex, 0x80);
590 DrawMenuObjectVibe((int) SysCur[0], (int) SysCur[1], 1, 0x40);
591}
592
593void DrawOtherCharaStatus(int x, int y, int chara, int alpha) {
594 int bar_x = x - 5;
595 int bar_y = y + 3;
596
597 if (bar_y > 0xDC) {
598 bar_y--;
599 }
600
601 CDngStatusData *status = BtlMenuStatusPt;
602 float hp = status->hp[chara];
603 float max_hp = status->max_hp[chara];
604
605 if (max_hp < 1.0f) {
606 max_hp = 1.0f;
607 }
608
609 int slot = status->equipped_weapon_slot[chara];
610 WEAPON_HAVE *weapons = status->chara_weapons[chara];
611 WEAPON_HAVE *weapon = &weapons[slot];
612
613 if (weapon == NULL) {
614 return;
615 }
616
617 float whp = weapon->durability_f;
618 float max_whp = weapon->durability;
619
620 if (max_whp < 1.0f) {
621 max_whp = 1.0f;
622 }
623
624 int water = (int) status->water_now[chara];
625 int max_water = (int) status->water_max[chara];
626 float values[4] = {hp, max_hp, whp, max_whp};
627 MGFillBox(CRect_i_((bar_x - 3) * 16, ((bar_y - 2) >> 1) * 16, 0x3A0, 0x30), 0x14, 0x14, 0x14, alpha);
628 int hp_len = (int) (52.0f * hp / max_hp);
629 MGFillBox(CRect_i_(bar_x * 16, (bar_y >> 1) * 16, 0x340, 0x20), 0x4F, 0x4F, 0x4F, alpha);
630 CRect_i_ hp_rect(bar_x * 16, (bar_y >> 1) * 16, hp_len * 16, 0x20);
631 int r = 0x4D;
632 int g = 0xE7;
633 int b = 0xA5;
634
635 if (!(15.6f < hp_len)) {
636 r = 0xD6;
637 g = 0x76;
638 b = 0xEA;
639 }
640
641 MGFillBox(hp_rect, r, g, b, alpha);
642 MGFillBox(CRect_i_((bar_x + 1) * 16, ((bar_y + 4) >> 1) * 16, 0x3A0, 0x30), 0x14, 0x14, 0x14, alpha);
643 float whp_len = 52.0f * whp / max_whp;
644 int whp_width = (int) whp_len;
645 MGFillBox(CRect_i_((bar_x + 4) * 16, ((bar_y + 6) >> 1) * 16, 0x340, 0x20), 0x4F, 0x4F, 0x4F, alpha);
646 MGFillBox(CRect_i_((bar_x + 4) * 16, ((bar_y + 6) >> 1) * 16, (int) whp_len * 16, 0x20), 0xFF, 0xB1, 0x49, alpha);
647 MGFillBox(CRect_i_((bar_x + 5) * 16, ((bar_y + 10) >> 1) * 16, 0x3A0, 0x40), 0x14, 0x14, 0x14, alpha);
648 int water_len = water * 0x34 / max_water;
649 MGFillBox(CRect_i_((bar_x + 8) * 16, ((bar_y + 12) >> 1) * 16, 0x340, 0x20), 0x4F, 0x4F, 0x4F, alpha);
650 MGFillBox(CRect_i_((bar_x + 8) * 16, ((bar_y + 12) >> 1) * 16, water_len * 16, 0x20), 0xC8, 0xEF, 0xF2, alpha);
651}
652
653void DngComStatus(int x, int y, int chara, int alpha) {
654 CTexture *texture = TexManager.GetTexture("charastb", -1);
655 int left = x - 6;
656 int fill;
657 int row_y;
658 float unused_scale[2] = {0.0f, 0.0f};
659 float hp = BtlMenuStatusPt->hp[chara];
660 float max_hp = BtlMenuStatusPt->max_hp[chara];
661
662 if (max_hp < 1.0f) {
663 max_hp = 32.0f;
664 }
665
666 int slot = BtlMenuStatusPt->equipped_weapon_slot[chara];
667 WEAPON_HAVE *weapons = BtlMenuStatusPt->chara_weapons[chara];
668 WEAPON_HAVE *weapon = &weapons[slot];
669
670 if (weapon == NULL) {
671 return;
672 }
673
674 float whp = weapon->durability_f;
675 float max_whp = weapon->durability;
676
677 if (max_whp < 1.0f) {
678 max_whp = 32.0f;
679 }
680
681 float values[2][2] = {
682 {hp, max_hp },
683 {whp, max_whp}
684 };
685 float full[2] = {200.0f, 99.0f};
686 int unused_colour[6] = {64, 212, 162, 255, 128, 0};
687 int colour_no[2] = {22, 25};
688 row_y = 0x50;
689
690 if (y % 2 == 0) {
691 y--;
692 }
693
694 for (int i = 0; i < 2; i++) {
695 int length = (int) (148.0f * values[i][1] / full[i]);
696 DrawMenu2DSprite(texture, CRect_i_(left + 0x10, y + 5, 4, 0xF), CRect_i_(0x10, 0xB0, 4, 0x10), alpha);
697 DrawMenu2DSprite(texture, CRect_i_(left + 0x14, y + 5, length, 0xF), CRect_i_(0x14, 0xB0, 4, 0x10), alpha);
698 DrawMenu2DSprite(texture, CRect_i_(left + 0x13 + length, y + 5, 4, 0xF), CRect_i_(0x18, 0xB0, 4, 0x10), alpha);
699 fill = (int) ((float) length * values[i][0] / values[i][1]);
700
701 if (i == 0) {
702 if (hp < 0.3f * max_hp) {
703 colour_no[i]++;
704 }
705
706 if (hp < 0.15f * max_hp) {
707 colour_no[i]++;
708 }
709 }
710
711 GRADATION_COLOR_INFO2 colours;
712 memcpy(&colours, GetGradationColorInfo2(colour_no[i]), sizeof(colours));
713 colours.colors[3].a = alpha;
714 colours.colors[2].a = alpha;
715 colours.colors[1].a = alpha;
716 colours.colors[0].a = alpha;
717 DrawMenuColorGradation(CRect_i_(left + 0x14, y + 6, fill, 6), &colours.colors[0], &colours.colors[1], &colours.colors[2], &colours.colors[3]);
718 int number_x = left + 0x4C + length;
719
720 while (x + 0x9A < number_x) {
721 number_x--;
722 }
723
724 int numbers[2];
725 numbers[0] = GetDispVolumeForFloat(values[i][0]);
726 numbers[1] = GetDispVolumeForFloat(values[i][1]);
727 DrawStatusNumberNowAndMax(numbers, number_x, y + 6, 1, alpha);
728 y += 0x10;
729 row_y += 0x10;
730 }
731
732 int drops = (int) BtlMenuStatusPt->water_max[chara] / 10;
733 int drop_x = left + 0x12;
734
735 for (int i = 0; i < drops - 1; i++) {
736 DrawMenu2DSprite(texture, CRect_i_(drop_x, y + 5, 0x12, 0x13), CRect_i_(0x22, 0x9C, 0x12, 0x14), alpha);
737 drop_x += 0x12;
738 }
739
740 DrawMenu2DSprite(texture, CRect_i_(drop_x, y + 5, 0x18, 0x14), CRect_i_(0x34, 0x9C, 0x18, 0x14), alpha);
741 int water_alpha = (alpha * 0x50) >> 7;
742 int full_drops = (int) BtlMenuStatusPt->water_now[chara] / 10;
743
744 for (int i = 0; i < full_drops; i++) {
745 DrawMenu2DSprite(texture, CRect_i_(left + 0x13 + i * 0x12, y, 0x10, 0x14), CRect_i_(0, 0x88, 0x10, 0x14), water_alpha);
746 }
747
748 int rest = (int) BtlMenuStatusPt->water_now[chara] % 10;
749
750 if (rest != 0) {
751 DrawMenu2DSprite(texture, CRect_i_(left + 0x13 + full_drops * 0x12, y, 0x10, 0x14), CRect_i_((3 - (int) ((float) rest / 2.5f)) * 16, 0x88, 0x10, 0x14), water_alpha);
752 }
753}
754
755void DrawSelCharaStatus(float x, float y, int chara, int alpha, int face_size, int face_alpha, int face_x, int face_y) {
756 int u;
757 int v;
758 int px = (int) (x - 144.0f);
759 float top = 1.0f + y;
760 int py = (int) (top - 24.0f);
761#ifdef PAL
762 CTexture *texture = TexManager.GetTexture("charastb", -1);
763#else
764 CTexture *texture = TexManager.GetTexture(CharaStatusTextureName, -1);
765#endif
766
767 DrawMenu2DSprite(texture, CRect_i_(px, py - 1, 0x100, 0x88), CRect_i_(0, 0, 0x100, 0x88), alpha);
768 RECT digits = {0x40, 0x88, 0xC, 0xE};
769 DrawMenuNumber((int) BtlMenuStatusPt->defense[chara], px + 0x5E, py + 0x72, texture, digits, 1, alpha);
770
771 px = (int) (x - 132.0f);
772 py = (int) (10.0f + y);
773 DngComStatus(px, py, chara, alpha);
774 px = (int) (x - 110.0f);
775 py = (int) (top - 18.0f);
776#ifdef PAL
777 CTexture *fonts[4] = {BtlAlpha, BtlKata, BtlHira, BtlEuro};
778#else
779 CTexture *fonts[3] = {BtlAlpha, BtlKata, BtlHira};
780#endif
781 CharaSelectNameDraw2(px, py, (short *) BtlMenuSaveDataPt->GetCharaName(chara), fonts, alpha);
782 px = (int) (x - 118.0f - 12.0f);
783 py = (int) (70.0f + y);
784 int slot = BtlMenuStatusPt->equipped_weapon_slot[chara];
785 WEAPON_HAVE *row = BtlMenuStatusPt->chara_weapons[chara];
786 WEAPON_HAVE *weapon = &row[slot];
787
788 if (weapon != NULL) {
789 CTexture *icon = RetCTex(weapon->item_no, u, v);
790
791 if (icon != NULL) {
792 WEAPON_HAVE total;
793 WeaponAllValueSet(weapon, &total, 0);
794 DrawMenu2DSprite(icon, CRect_i_(px + 2, py + 2, 0x20, 0x20), CRect_i_(u, v, 0x20, 0x20), alpha);
795 DrawMenuNumber(total.attack, px + 0x20, py + 0x14, texture, digits, 1, alpha);
796 }
797 }
798
799 px = (int) (x - 34.0f);
800 py = (int) (64.0f + y);
801 px = (int) (x - 40.0f);
802 CharaStatusMsgDraw(px, (int) (68.0f + y), chara, 1, alpha);
803}
804
808static void DrawBtlAtoraSelect() {
809 DrawMenuAtoraSelect();
810}
811
815static void BtlDrawOption() {
816 DrawMenuOption();
817 setbilinear(0);
818}
819
827static void BtlDrawSave() {
828 DrawMenuSave("frame_image");
829 setbilinear(0);
830}
831
839static void BtlMenuTexBlockEnter() {
840 MenuCharaFace = TexManager.GetTexture("charaface", BtlMenuReadBlock);
841 BtStatus = TexManager.GetTexture("btstatus2", BtlMenuReadBlock);
842 WepIcon = TexManager.GetTexture("wepicon", -1);
843 ItemIcon = TexManager.GetTexture("itemicon", BtlMenuReadBlock);
844 PerBoardTex = TexManager.GetTexture("perbrd", BtlMenuReadBlock);
845#ifdef PAL
846 WepStatus = TexManager.GetTexture("wepstatus", BtlMenuExtBlock);
847#else
848 WepStatus = TexManager.GetTexture("wepstatus", BtlMenuReadBlock);
849#endif
850 VillageName = TexManager.GetTexture("vilname", -1);
851 VillageBar = TexManager.GetTexture("viltag", -1);
852}
853
854#ifdef PAL
855void BattleMenuTexEnter() {
856 LOADTEXTURE_INFO2 textures[6] = {
857 {"#frame_image#640#480#4", 0, 0},
858 {"#dbgwork_menu#256#256#3", 0, 0},
859 {NULL, 0, 0},
860 {"#frame_image_2#640#480#4", 0, 0},
861 {NULL, 0, 0},
862 {NULL, 0, 0}
863 };
864
865 textures[0].block_no = BtlMenuReadBlock;
866 textures[1].block_no = BtlMenuReadBlock;
867 textures[2].block_no = BtlMenuReadBlock;
868 textures[3].block_no = BtlMenuExtBlock;
869 textures[4].block_no = BtlMenuExtBlock;
870 BG_READ_INFO *file = GetReadBGFile(0);
871 textures[2].name = (char *) GetPackFile((u_int *) file->buffer, "btlmenu.img", NULL);
872 textures[4].name = (char *) GetPackFile((u_int *) file->buffer, "btlmenu2.img", NULL);
873 int blocks[3] = {0, 0, -1};
874 blocks[0] = BtlMenuReadBlock;
875 blocks[1] = BtlMenuExtBlock;
876 MenuTextureDelete(blocks);
877 TexManager.CleanUpTextureList();
878 TexManager.LoadTextureBlockEX(-1, textures);
879 BtlMenuTexBlockEnter();
880 GetAtraMsgReadBuf = (short *) GetPackFile((u_int *) file->buffer, "atrames.bin", NULL);
881 short *mes = (short *) GetPackFile((u_int *) file->buffer, "allmenu.mes", NULL);
882 InitMenuMesSet(MENU_MES_SET_ALLMENU, mes);
883 CommonMenuMes2.stay_frame = false;
884 BtlMenuReadEndFlag = 1;
885 MenuMes.SetBuffInfo(mes);
886}
887#else
888void BattleMenuTexEnter() {
889 LOADTEXTURE_INFO2 textures[4] = {
890 {"#frame_image#640#448#4", 0, 0},
891 {"#dbgwork_menu#256#224#3", 0, 0},
892 {NULL, 0, 0},
893 {NULL, 0, 0}
894 };
895
896 textures[0].block_no = BtlMenuReadBlock;
897 textures[1].block_no = BtlMenuReadBlock;
898 textures[2].block_no = BtlMenuReadBlock;
899 BG_READ_INFO *file = GetReadBGFile(0);
900 textures[2].name = (char *) GetPackFile((u_int *) file->buffer, "btlmenu.img", NULL);
901 int blocks[2] = {0, -1};
902 blocks[0] = BtlMenuReadBlock;
903 MenuTextureDelete(blocks);
904 TexManager.CleanUpTextureList();
905 TexManager.LoadTextureBlockEX(-1, textures);
906 BtlMenuTexBlockEnter();
907 GetAtraMsgReadBuf = (short *) GetPackFile((u_int *) file->buffer, "atrames.bin", NULL);
908 short *mes = (short *) GetPackFile((u_int *) file->buffer, "allmenu.mes", NULL);
909 InitMenuMesSet(MENU_MES_SET_ALLMENU, mes);
910 CommonMenuMes2.stay_frame = false;
911 BtlMenuReadEndFlag = 1;
912 MenuMes.SetBuffInfo(mes);
913}
914#endif
915
916void ExitBattleMenu(int unused) {
917 int count = 0;
918 s16 *item = MenuItemPackPt->item;
919
920 for (int i = 0; i < MenuItemPackPt->num; i++, item++) {
921 if (*item >= ITEM_DUNGEON_START) {
922 count++;
923 } else {
924 *item = -1;
925 }
926 }
927
928 item = MenuItemPackPt->quick_item_slot;
929
930 for (int i = 0; i < 3; i++, item++) {
931 if (*item >= ITEM_DUNGEON_START) {
932 count += MenuItemPackPt->quick_item_qty[i];
933 } else {
934 *item = -1;
935 MenuItemPackPt->quick_item_qty[i] = 0;
936 }
937 }
938
939 MenuItemPackPt->item_count = count;
940#ifdef PAL
941 int blocks[7] = {0, 0, 0, 0, 0, 0, -1};
942#else
943 int blocks[6] = {0, 0, 0, 0, 0, -1};
944#endif
945 blocks[0] = BtlMenuReadBlock;
946 blocks[1] = MenuExtendReadBlock;
947 blocks[2] = BtlMenuExReadBlock;
948 blocks[3] = BtlMenuManualReadBlock;
949 blocks[4] = MenuShadowReadBlock;
950#ifdef PAL
951 blocks[5] = BtlMenuExtBlock;
952#endif
953 MenuTextureDelete(blocks);
954 TexManager.CleanUpBuffer();
955 TexManager.CleanUpTextureList();
956 ItemVolumeStep.Initialize();
957 MenuWepLevelUp.CheckSnd();
958
959 switch (BtlMenuMode) {
960 case BATTLE_MENU_MODE_DUNGEON: {
961 LOADTEXTURE_INFO2 textures[2] = {
962 {"#frame_image0#640#" SCREEN_HEIGHT_STR "#4", 0, 0},
963 {NULL, 0, 0}
964 };
965 textures[0].block_no = BtlMenuReadBlock;
966 TexManager.LoadTextureBlock(-1, textures);
967 break;
968 }
969 }
970
971 SndSetBgmVol(BtlMenuBGMvol);
972 InitReadBG();
973 GamePad.AutoRepeatOff();
974 GamePad.MenuModeOff();
975}
976
977void BattleMenuInit(int *texture_blocks, int mode) {
978 BtlMenuMode = mode;
979 BtlMenuReadBlock = texture_blocks[0];
980 MenuExtendReadBlock = texture_blocks[1];
981 BtlMenuExReadBlock = texture_blocks[2];
982 BtlMenuManualReadBlock = texture_blocks[3];
983 ItemMenuWeaponIconReadBlock = texture_blocks[3];
984 MenuShadowReadBlock = texture_blocks[4];
985#ifdef PAL
986 BtlMenuExtBlock = texture_blocks[5];
987#endif
988 BtlMenuNowLang = GetMenuLangFlag();
989 GamePad.SetAutoRepeat(PAD_DPAD, 0x1E, 5);
990 GamePad.MenuModeOn(0x78);
991
992 switch (BtlMenuMode) {
993 case BATTLE_MENU_MODE_DUNGEON: {
994 LOADTEXTURE_INFO2 texture[2] = {
995 {"#frame_image#640#" SCREEN_HEIGHT_STR "#4", 0, 0},
996 {NULL, 0, 0}
997 };
998 texture[0].block_no = BtlMenuReadBlock;
999#ifdef PAL
1000 int blocks[7] = {0, 0, 0, 0, 0, 0, -1};
1001#else
1002 int blocks[6] = {0, 0, 0, 0, 0, -1};
1003#endif
1004 blocks[0] = BtlMenuReadBlock;
1005 blocks[1] = MenuExtendReadBlock;
1006 blocks[2] = BtlMenuExReadBlock;
1007 blocks[3] = BtlMenuManualReadBlock;
1008 blocks[4] = MenuShadowReadBlock;
1009#ifdef PAL
1010 blocks[5] = BtlMenuExtBlock;
1011#endif
1012 MenuTextureDelete(blocks);
1013 TexManager.CleanUpBuffer();
1014 TexManager.CleanUpTextureList();
1015 TexManager.LoadTextureBlockEX(-1, texture);
1016 break;
1017 }
1018 }
1019
1020 BtlMenuReadBuf = BtlMenuBufferSet(BtlMenuMode);
1021 BtlMenuReadBuf = MenuCalcBufAlignment(BtlMenuReadBuf);
1022 StartReadBG();
1023 int size = LoadFileBGMenuData("dungeon/dunmenu5.pak", BtlMenuReadBuf);
1024 ReadBG();
1025 BtlMenuReadBuf += (size >> 4) + 1;
1026 BtlMenuReadBuf = MenuCalcBufAlignment(BtlMenuReadBuf);
1027 BtlMenuExReadFlag = 1;
1028 BtlMenuReadEndFlag = 0;
1029 MenuExTextureReadFlag = MENU_EX_TEX_UNREAD;
1030 MenuMes.InitMes();
1031 MenuMes.work_area = BtlMenuReadBuf;
1032 printf("msg work area\n");
1033 BtlMenuReadBuf += 0x11;
1034 BtlMenuReadBuf = MenuCalcBufAlignment(BtlMenuReadBuf);
1035 StayTex = TexManager.GetTexture("stayframe", -1);
1036 WepIcon = NULL;
1037 ItemIcon = NULL;
1038 ItemIcon2 = NULL;
1039 AttachIcon = NULL;
1040 BtlMenuSaveDataPt = SaveData;
1041
1042 switch (BtlMenuMode) {
1043 case BATTLE_MENU_MODE_DUNGEON:
1044 MenuMapJumpMode = 0;
1045 BtlMenuStatusPt = (CDngStatusData *) UserStatus;
1046 SetEscapeDngFlag(EscapeDungeonMode());
1047 break;
1048 case BATTLE_MENU_MODE_TOWN:
1049 MenuMapJumpMode = -1;
1050 BtlMenuStatusPt = SaveData->GetDngStatus();
1051 SetEscapeDngFlag(ESCAPE_DNG_PAY);
1052 break;
1053 }
1054
1055 SetInteriorOutFlag(0);
1056 DngWepHavePt = BtlMenuStatusPt->chara_weapons[0];
1057 MenuItemPackPt = &BtlMenuStatusPt->item_pack;
1058 MenuChara.slot_count = 6;
1059 PosAngle = TWO_PI / MenuChara.slot_count;
1060
1061#ifdef PAL
1062 // Debug builds hand the controlled character a place in the party along with a weapon.
1063 if (DebugMode && BtlMenuStatusPt->cur_chara > BtlMenuStatusPt->party_size - 1) {
1064 BtlMenuStatusPt->party_size = BtlMenuStatusPt->cur_chara + 1;
1065 BtlMenuStatusPt->GetItem(GetDefaultWeaponNo(BtlMenuStatusPt->party_size - 1) + 1, 0);
1066 EquipDefaultWeapon(BtlMenuStatusPt->party_size - 1);
1067 printf("Debug Party Member Get\n");
1068 }
1069
1070#endif
1071 ItemVolumeStep.CheckItemVolume();
1072 CursorVibeCnt = 0;
1073 BtlHelpWinAlpha = 0;
1074 GetMainMenuRightHelpWinLangOffset(HelpWinHead[0], HelpWinHead[1], BtlHelpWinW, BtlHelpWinH);
1075 BtlWakuMake2 = 1;
1076 MenuSelect[0] = BTLMENU_PAGE_ITEM;
1077 MenuSelect[1] = 0;
1078
1079 for (int i = 0; i < 8; i++) {
1080 NorMenuIcon[i].x = -150.0f;
1081 NorMenuIcon[i].y = i * 0x28 + 0x30;
1082 }
1083
1084 if (CheckItemThrow(NULL, NULL) != 0) {
1085 BattleMenuFlag = BTLMENU_STATE_ITEM_TRUSH;
1086 BtlEffectFlag = BTLEFFECT_NONE;
1087 BtlMenuStatusPt->overflow_flag = true;
1088
1089 for (int i = 1; i < 8; i++) {
1090 NorMenuIcon[i].x = -230.0f;
1091 }
1092
1093 NorMenuIcon[0].x = 70.0f;
1094 NorMenuIcon[0].y = 28.0f;
1095 } else {
1096 BattleMenuFlag = BTLMENU_STATE_APPEAR;
1097 BtlEffectFlag = BTLEFFECT_NONE;
1098 }
1099
1100 MenuChara.state = MENU_CHARA_OPEN;
1101 MenuWepLevelUp.Initialize();
1102 BtlEffectCt = 0;
1103 MenuWarningMsgFlag = 0;
1104 BtlMenuBGMvol = SndGetBgmVol();
1105}
1106
1114static int BtlMenuDrawSpecialFlag(int flag) {
1115 if ((BattleMenuFlag == BTLMENU_STATE_ATLA_OPEN || BattleMenuFlag == BTLMENU_STATE_ATLA || BattleMenuFlag == BTLMENU_STATE_ATLA_CLOSE) && GetMenuAtraEventFlag() != 0) {
1116 flag = 0;
1117 }
1118
1119 if (MenuChara.state == MENU_CHARA_CHANGE_LOAD || MenuChara.state == MENU_CHARA_CHANGE_EXIT) {
1120 flag = 0;
1121 }
1122
1123 return flag;
1124}
1125
1126void BattleMenuDraw() {
1127 int text_x;
1128 int text_y;
1129
1130 setbilinear(0);
1131 MenuWorldTrans(&MenuCamera);
1132 sceVif1PkCall(GetVif1Packet(), (u_long128 *) Vu_prog0f, 0);
1133 sceVif1PkTerminate(GetVif1Packet());
1134 MenuTextureReload(BtlMenuReadBlock);
1135 CTexture frame = *TexManager.GetTexture("frame_image", -1);
1136 CTexture *texture = &frame;
1137 int tcc = 0;
1138
1139 if (texture != NULL) {
1140 ((sceGsTex0 *) &frame.tex0)->bits.tcc = tcc;
1141 } else {
1142 return;
1143 }
1144
1145 int bright = 0x40;
1146
1147 switch (BattleMenuFlag) {
1148 case BTLMENU_STATE_APPEAR:
1149 bright = (int) (128.0f - 4.0f * BtlEffectCt);
1150
1151 if (bright < 0x40) {
1152 bright = 0x40;
1153 }
1154
1155 break;
1156 case BTLMENU_STATE_EXIT:
1157 bright += 4.0f * BtlEffectCt;
1158
1159 if (bright > 0x80) {
1160 bright = 0x80;
1161 }
1162
1163 break;
1164 }
1165
1166 DrawMenu2DSprite(&frame, MenuDispRc, MenuDispRc, bright, bright, bright, 0x80);
1167
1168 switch (BattleMenuFlag) {
1169 case BTLMENU_STATE_MAIN:
1170 DrawBattleMain();
1171 break;
1172 case BTLMENU_STATE_CHARA:
1173 case BTLMENU_STATE_CHARA_OPEN:
1174 case BTLMENU_STATE_CHARA_CLOSE:
1175 case BTLMENU_STATE_UNK_1A:
1176 DrawCharaSelect();
1177 break;
1178 case BTLMENU_STATE_WEAPON:
1179 case BTLMENU_STATE_WEAPON_OPEN:
1180 case BTLMENU_STATE_WEAPON_CLOSE:
1181 WeaponMenuDraw();
1182 break;
1183 case BTLMENU_STATE_ITEM:
1184 case BTLMENU_STATE_ITEM_OPEN:
1185 case BTLMENU_STATE_ITEM_CLOSE:
1186 ItemMenuModeDraw();
1187 break;
1188 case BTLMENU_STATE_ATLA:
1189 case BTLMENU_STATE_ATLA_OPEN:
1190 case BTLMENU_STATE_ATLA_CLOSE:
1191 DrawBtlAtoraSelect();
1192 break;
1193 case BTLMENU_STATE_MOVE:
1194 case BTLMENU_STATE_MOVE_OPEN:
1195 case BTLMENU_STATE_MOVE_CLOSE:
1196 DrawMenuMove();
1197 break;
1198 case BTLMENU_STATE_OPTION:
1199 case BTLMENU_STATE_OPTION_OPEN:
1200 case BTLMENU_STATE_OPTION_CLOSE:
1201 BtlDrawOption();
1202 break;
1203 case BTLMENU_STATE_SAVE:
1204 case BTLMENU_STATE_SAVE_OPEN:
1205 case BTLMENU_STATE_SAVE_CLOSE:
1206 BtlDrawSave();
1207 break;
1208 case BTLMENU_STATE_MANUAL:
1209 case BTLMENU_STATE_MANUAL_OPEN:
1210 case BTLMENU_STATE_MANUAL_CLOSE:
1211 BattleManualDraw();
1212 break;
1213 }
1214
1215 CursorVibeCnt++;
1216
1217 if (CursorVibeCnt >= 0x405F7E00) {
1218 CursorVibeCnt = 0;
1219 }
1220
1221 int draw_help = BtlMenuDrawSpecialFlag(BtlWakuMake2);
1222
1223 if (BtlMenuReadEndFlag != 0) {
1224 switch (BattleMenuFlag) {
1225 case BTLMENU_STATE_EXIT:
1226 BtlHelpWinAlpha -= 8;
1227
1228 if (BtlHelpWinAlpha < 0) {
1229 BtlHelpWinAlpha = 0;
1230 }
1231
1232 break;
1233 default:
1234 BtlHelpWinAlpha += 9;
1235
1236 if (BtlHelpWinAlpha > 0x80) {
1237 BtlHelpWinAlpha = 0x80;
1238 }
1239
1240 break;
1241 }
1242
1243 if (draw_help != 0) {
1244 MenuHelpWinDraw((int) HelpWinHead[0], (int) HelpWinHead[1], BtlHelpWinW, BtlHelpWinH, BtlHelpWinAlpha);
1245 }
1246 }
1247
1248 MenuTextureReload(CommonMenuMes2.tex_block);
1249 GetMainMenuRightHelpMsgLangOffset(text_x, text_y);
1250 CommonMenuMes2.text_x = (int) (HelpWinHead[0] + text_x);
1251 CommonMenuMes2.text_y = (int) (HelpWinHead[1] + text_y);
1252
1253 if (BtlMenuReadEndFlag != 0 && draw_help != 0) {
1254 CommonMenuMes2.stay_frame = false;
1255 CommonMenuMes2.edge_alpha = BtlHelpWinAlpha;
1256 CommonMenuMes2.Step();
1257 CommonMenuMes2.DrawMesWin();
1258 }
1259
1260 setbilinear(0);
1261 draw_help = BtlMenuDrawSpecialFlag(1);
1262
1263 if (draw_help != 0) {
1264 DrawBtlMenuBar();
1265 }
1266
1267 if (WepMenu.mode != WEP_MENU_BUILDUP_SELECT) {
1268 MenuWepLevelUp.Step();
1269 MenuWepLevelUp.Draw();
1270 }
1271
1272 if (GetInteriorOutFlag() != 0) {
1273 BtlEffectCt += 1.0f;
1274 int fade = (int) (3.0f * BtlEffectCt);
1275
1276 if (fade > 0x80) {
1277 fade = 0x80;
1278 }
1279
1280 AllFadeForMenu(fade);
1281 }
1282
1283 setbilinear(1);
1284}
1285
1286int BattleMenuCursor() {
1287 int result;
1288
1289 ReadBG();
1290 ((CUserStatus *) BtlMenuStatusPt)->Step(1);
1291 ItemVolumeStep.LoopStep(0x3C);
1292 ItemVolumeStep.CheckItemVolume();
1293 result = 1;
1294
1295 switch (BattleMenuFlag) {
1296 case BTLMENU_STATE_APPEAR:
1297 BattleMenuAppear();
1298 break;
1299 case BTLMENU_STATE_EXIT:
1300 result = BattleMenuExit();
1301 break;
1302 case BTLMENU_STATE_MAIN:
1303 result = BattleMenuSelect();
1304 break;
1305 case BTLMENU_STATE_WEAPON:
1306 case BTLMENU_STATE_WEAPON_OPEN:
1307 case BTLMENU_STATE_WEAPON_CLOSE:
1308 WeaponMenuSelect();
1309 break;
1310 case BTLMENU_STATE_ITEM_TRUSH:
1311 InitItemTrushStart();
1312 break;
1313 case BTLMENU_STATE_ITEM:
1314 case BTLMENU_STATE_ITEM_OPEN:
1315 case BTLMENU_STATE_ITEM_CLOSE:
1316 ItemMenuMainKey();
1317 break;
1318 case BTLMENU_STATE_CHARA:
1319 case BTLMENU_STATE_CHARA_OPEN:
1320 case BTLMENU_STATE_CHARA_CLOSE:
1321 case BTLMENU_STATE_UNK_1A:
1322 result = BattleMenuCharaKey();
1323 break;
1324 case BTLMENU_STATE_ATLA:
1325 case BTLMENU_STATE_ATLA_OPEN:
1326 case BTLMENU_STATE_ATLA_CLOSE:
1327 BattleMenuAtoraKey();
1328 break;
1329 case BTLMENU_STATE_MOVE:
1330 case BTLMENU_STATE_MOVE_OPEN:
1331 case BTLMENU_STATE_MOVE_CLOSE:
1332 result = MenuMoveKey();
1333 break;
1334 case BTLMENU_STATE_OPTION:
1335 case BTLMENU_STATE_OPTION_OPEN:
1336 case BTLMENU_STATE_OPTION_CLOSE:
1337 BattleMenuOptionKey();
1338 break;
1339 case BTLMENU_STATE_SAVE:
1340 case BTLMENU_STATE_SAVE_OPEN:
1341 case BTLMENU_STATE_SAVE_CLOSE:
1342 BattleMenuSaveKey();
1343 break;
1344 case BTLMENU_STATE_MANUAL:
1345 case BTLMENU_STATE_MANUAL_OPEN:
1346 case BTLMENU_STATE_MANUAL_CLOSE:
1347 BattleManualKey();
1348 break;
1349 }
1350
1351 MenuWepLevelUp.StepSnd();
1352
1353 switch (BtlMenuMode) {
1354 case BATTLE_MENU_MODE_DUNGEON:
1355 SetEscapeDngFlag(EscapeDungeonMode());
1356 break;
1357 }
1358
1359 return result;
1360}
1361
1369static void BattleMenuAppear() {
1370 int arrived = false;
1371 int i;
1372 int position[2];
1373
1374 for (i = 0; i < GetMenuModeMax(); i++) {
1375 GetMenuIconPos(i, position);
1376 float x = NorMenuIcon[i].x;
1377 float dx = position[0] - x;
1378 NorMenuIcon[i].x = x + dx / 4.0f;
1379 NorMenuIcon[i].y += (position[1] - NorMenuIcon[i].y) / 4.2f;
1380
1381 if (dx < 3.4f) {
1382 NorMenuIcon[i].x = position[0];
1383 arrived++;
1384 }
1385 }
1386
1387 BtlEffectCt += 1.0f;
1388
1389 if (!(BtlEffectCt < 19.0f)) {
1390 BtlEffectCt = 19.0f;
1391 }
1392
1393 int reading = ReadBGSync();
1394
1395 if (arrived >= 6 && reading == 0) {
1396 BattleMenuTexEnter();
1397 BtlMenuReadEndFlag = 1;
1398 BtlEffectCt = 0.0f;
1399 BtlEffectFlag = BTLEFFECT_NONE;
1400 BattleMenuFlag = BTLMENU_STATE_MAIN;
1401 MenuSelect[0] = BTLMENU_PAGE_ITEM;
1402 MenuSelect[1] = 0;
1403 SysCur[0] = 64.0f;
1404 SysCur[1] = 54.0f;
1405 }
1406}
1407
1415static int BattleMenuExit() {
1416 int i;
1417
1418 for (i = 0; i < GetMenuModeMax(); i++) {
1419 NorMenuIcon[i].x += (-198.0f - NorMenuIcon[i].x) / 4.0f;
1420 }
1421
1422 BtlEffectCt += 1.0f;
1423
1424 if (!(BtlEffectCt <= 20.0f) && ReadBGSync() == 0) {
1425 ExitBattleMenu(1);
1426 return 0;
1427 }
1428
1429 return 1;
1430}
1431
1432int BattleMenuSelect() {
1433 if (MenuWarningMsgFlag != 0) {
1434 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
1435 MenuWarningMsgFlag = 0;
1436 }
1437
1438 return 1;
1439 }
1440
1441 int old = MenuSelect[1];
1442 int max = GetMenuModeMax();
1443
1444 if (GamePad.Down(PAD_UP | PAD_LEFT) != 0) {
1445 MenuSelect[1]--;
1446
1447 if (MenuSelect[1] < 0) {
1448 MenuSelect[1] = max - 1;
1449 }
1450 }
1451
1452 if (GamePad.Down(PAD_RIGHT | PAD_DOWN) != 0) {
1453 MenuSelect[1]++;
1454
1455 if (MenuSelect[1] > max - 1) {
1456 MenuSelect[1] = 0;
1457 }
1458 }
1459
1460 if (old != MenuSelect[1]) {
1461 ComMenuSePlay(MENU_SOUND_CURSOR);
1462 }
1463
1464 if (GamePad.Down(PAD_CROSS) != 0) {
1465 int pages[2][8] = {
1466 {BTLMENU_PAGE_ITEM, BTLMENU_PAGE_WEAPON, BTLMENU_PAGE_CHARA, BTLMENU_PAGE_ATLA, BTLMENU_PAGE_MOVE, BTLMENU_PAGE_OPTION, BTLMENU_PAGE_MANUAL, BTLMENU_PAGE_NONE },
1467 {BTLMENU_PAGE_ITEM, BTLMENU_PAGE_WEAPON, BTLMENU_PAGE_CHARA, BTLMENU_PAGE_ATLA, BTLMENU_PAGE_MOVE, BTLMENU_PAGE_SAVE, BTLMENU_PAGE_OPTION, BTLMENU_PAGE_MANUAL}
1468 };
1469 MenuSelect[0] = pages[BtlMenuMode][MenuSelect[1]];
1470 CommonMenuMes1.stay_frame = false;
1471 CUserStatus *status = (CUserStatus *) BtlMenuStatusPt;
1472 int chara = status->cur_chara;
1473 u_long128 *buffer = BtlMenuReadBuf;
1474
1475 switch (MenuSelect[0]) {
1476 case BTLMENU_PAGE_CHARA:
1477 if (BtlMenuMode == BATTLE_MENU_MODE_DUNGEON) {
1478 int zone = status->res_limit_zone_current;
1479
1480 if (zone < 6 && zone >= 0) {
1481 ComMenuSePlay(MENU_SOUND_REFUSE);
1482 return 1;
1483 }
1484 }
1485
1486 InitMenuChara(buffer);
1487 break;
1488 case BTLMENU_PAGE_WEAPON:
1489 InitWeaponSelect(WEP_OPEN_FROM_BAR, chara);
1490 break;
1491 case BTLMENU_PAGE_ITEM:
1492 InitItemMode(0, chara);
1493 break;
1494 case BTLMENU_PAGE_ATLA: {
1495 int blocks[2] = {0, 0};
1496 blocks[0] = BtlMenuReadBlock;
1497 blocks[1] = MenuExtendReadBlock;
1498 int map = 0;
1499
1500 switch (BtlMenuMode) {
1501 case BATTLE_MENU_MODE_DUNGEON:
1502 map = status->cur_georama;
1503
1504 if (map < 0) {
1505 map = 0;
1506 }
1507
1508 if (map >= 6) {
1509 map = 0;
1510 }
1511
1512 break;
1513 case BATTLE_MENU_MODE_TOWN:
1514 map = GetNowMapTransAtraMap(MapNo);
1515
1516 if (map < 0 || map > 5) {
1517 map = 0;
1518 }
1519
1520 break;
1521 }
1522
1523 InitMenuAtora1(BtlMenuMode, map, blocks, buffer);
1524 InitMenuAtoraSelect(map);
1525 break;
1526 }
1527 case BTLMENU_PAGE_MOVE: {
1528 int flag = NowGetGameFlagForBtlMenu(BtlMenuMode);
1529
1530 switch (flag) {
1531 case MENU_MOVE_LOCKED:
1532 ComMenuSePlay(MENU_SOUND_REFUSE);
1533 return 1;
1534 default:
1535 case MENU_MOVE_WORLD_MAP:
1536 case MENU_MOVE_FIRST_DUNGEON:
1537 case MENU_MOVE_INTERIOR_OUT:
1538 case MENU_MOVE_DUNGEON_ESCAPE:
1539 InitMenuMove(flag, MenuExtendReadBlock, buffer);
1540 BtlWakuMake2 = 0;
1541 break;
1542 }
1543
1544 break;
1545 }
1546 case BTLMENU_PAGE_OPTION:
1547 InitMenuOption(OPTION_OPEN_GAME_MENU, MenuExtendReadBlock, buffer);
1548 break;
1549 case BTLMENU_PAGE_SAVE:
1550 BtlWakuMake2 = 0;
1551 InitMenuSave(SAVE_MENU_MODE_SAVE, MenuExtendReadBlock, buffer);
1552 break;
1553 case BTLMENU_PAGE_MANUAL: {
1554 BtlWakuMake2 = 0;
1555 int blocks[3] = {0, 0, 0};
1556 blocks[0] = MenuExtendReadBlock;
1557 blocks[1] = BtlMenuExReadBlock;
1558 blocks[2] = BtlMenuManualReadBlock;
1559 BattleManualInit(blocks, buffer);
1560 break;
1561 }
1562 }
1563
1564 BattleMenuFlag = MenuSelect[0] + BTLMENU_STATE_OPEN_OFFSET;
1565 BtlEffectFlag = BTLEFFECT_PAGE_OPEN;
1566 BtlEffectCt = 0;
1567 ComMenuSePlay(MENU_SOUND_CONFIRM);
1568 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
1569 ComMenuSePlay(MENU_SOUND_REFUSE);
1570 BattleMenuFlag = BTLMENU_STATE_EXIT;
1571 }
1572
1573 return 1;
1574}
1575
1576int ToFromSelect(int out) {
1577 if (out < 0 || out > 1) {
1578 return -1;
1579 }
1580
1581 int home[8][2] = {
1582 {70, 28},
1583 {100, 48},
1584 {86, 38},
1585 {50, 40},
1586 {90, 40},
1587 {94, 30},
1588 {80, 40},
1589 {70, 28}
1590 };
1591 int pos[2];
1592#ifdef PAL
1593 float hide_x = -240.0f;
1594
1595 if (BtlMenuNowLang > LANG_JAPANESE) {
1596 hide_x = -264.0f;
1597 }
1598
1599#else
1600 float hide_x = -224.0f;
1601
1602 if (BtlMenuNowLang > LANG_JAPANESE) {
1603 hide_x = -258.0f;
1604 }
1605
1606#endif
1607 int done = 0;
1608 int arrived = false;
1609
1610 for (int i = 0; i < GetMenuModeMax(); i++) {
1611 int axes = 0;
1612
1613 if (out != 0) {
1614 GetMenuIconPos(i, pos);
1615 } else if (i != MenuSelect[1]) {
1616 pos[0] = (int) hide_x;
1617 pos[1] = i * 0x28 + 0x48;
1618 } else {
1619 pos[0] = home[i][0];
1620 pos[1] = home[i][1];
1621 }
1622
1623 float dx = (float) pos[0] - NorMenuIcon[i].x;
1624 float dy = (float) pos[1] - NorMenuIcon[i].y;
1625 NorMenuIcon[i].x += dx / 4.0f;
1626 NorMenuIcon[i].y += dy / 4.0f;
1627
1628 if ((float) abs((int) dx) < 2.0f) {
1629 NorMenuIcon[i].x = pos[0];
1630 axes++;
1631 }
1632
1633 if ((float) abs((int) dy) < 2.0f) {
1634 NorMenuIcon[i].y = pos[1];
1635 axes++;
1636 }
1637
1638 if (axes >= 2) {
1639 arrived++;
1640 }
1641 }
1642
1643 if (arrived >= 6) {
1644 done = 1;
1645 }
1646
1647 return done;
1648}
1649
1657static void ForBackMenu() {
1658 int position[2];
1659
1660 BtlEffectCt = 0.0f;
1661 BtlEffectFlag = BTLEFFECT_NONE;
1662 BtlWakuMake2 = 1;
1663 CommonMenuMes1.mes_made = -1;
1664 CommonMenuMes1.auto_pos = MES_POS_NONE;
1665 CommonMenuMes1.edge_alpha = 128;
1666
1667 for (int i = 0; i < 10; i++) {
1668 CommonMenuMes1.mes_no[i] = -1;
1669 CommonMenuMes1.values[i] = -1;
1670 }
1671
1672 MenuSelect[0] = BattleMenuFlag - BTLMENU_STATE_CLOSE_OFFSET;
1673 GetMenuIconPos(MenuSelect[1], position);
1674 SysCur[0] = position[0] - 40;
1675 SysCur[1] = position[1] + 20;
1676}
1677
1685static void InitMenuChara(u_long128 *buffer) {
1686 StartReadBG();
1687 LoadFileBGMenuData("charatex.img", buffer);
1688 ReadBG();
1689 BtlMenuExReadFlag = 0;
1690 MenuChara.state = MENU_CHARA_OPEN;
1691 MenuChara.timer = 0.0f;
1692 chara_r_long = 118.0f;
1693 BtlEffectCt = 0.0f;
1694 MenuCharaMove = 0.0f;
1695 SysCur[0] = 60.0f;
1696 SysCur[1] = 160.0f;
1697 CDngStatusData *status = BtlMenuStatusPt;
1698 int chara = status->cur_chara;
1699 MenuChara.chara = chara;
1700
1701 for (int i = 0; i < MenuChara.slot_count; i++) {
1702 SysChara[i].place = i - chara;
1703 SysChara[i].chara = i;
1704 SysChara[i].x = 0;
1705 SysChara[i].y = 0;
1706
1707 if (SysChara[i].place < 0) {
1708 SysChara[i].place = MenuChara.slot_count + SysChara[i].place;
1709 }
1710 }
1711
1712 int message_no = chara + 30;
1713
1714 if (status->party_size - 1 < chara) {
1715 message_no = 39;
1716 }
1717
1718 CommonMenuMes2.mes_made = -1;
1719 CommonMenuMes2.MakeMesWin(message_no);
1720}
1721
1722#pragma opt_propagation off
1723
1724int BattleMenuCharaKey() {
1725 switch (MenuChara.state) {
1726 case MENU_CHARA_CHANGE_LOAD:
1727 MenuChara.change_counter++;
1728
1729 if (ReadBGSync() == 0 && MenuChara.change_counter > 20) {
1730 BtMenuLoadChara();
1731 BreakReadBG();
1732 StartReadBG();
1733 CharaChangeInitToGL2(1);
1734 MenuChara.state = MENU_CHARA_CHANGE_EXIT;
1735 }
1736
1737 break;
1738 case MENU_CHARA_CHANGE_EXIT:
1739 MenuChara.change_counter++;
1740
1741 if (ReadBGSync() == 0 && MenuChara.change_counter > 20) {
1742 BtMenuLoad2(1);
1743 LockOffTargte();
1744 ExitBattleMenu(1);
1745 return 0;
1746 }
1747
1748 break;
1749 case MENU_CHARA_OPEN: {
1750 if (BtlMenuExReadFlag == 0) {
1751 if (ReadBGSync() == 0) {
1752 LOADTEXTURE_INFO2 texture[3] = {
1753 {"#frame_image_charamenu#640#" SCREEN_HEIGHT_STR "#4", 0, 0},
1754 {NULL, 0, 0},
1755 {NULL, 0, 0}
1756 };
1757 texture[0].block_no = BtlMenuExReadBlock;
1758 texture[1].block_no = BtlMenuExReadBlock;
1759 BG_READ_INFO *file = GetReadBGFile(0);
1760 texture[1].name = (char *) file->buffer;
1761 BtlMenuCharaChangeBuf = file->buffer + (file->size >> 4) + 1;
1762 BtlMenuCharaChangeBuf = MenuCalcBufAlignment(BtlMenuCharaChangeBuf);
1763 int blocks[2] = {0, -1};
1764 blocks[0] = BtlMenuExReadBlock;
1765 MenuTextureDelete(blocks);
1766 TexManager.CleanUpTextureList();
1767 TexManager.LoadTextureBlockEX(-1, texture);
1768 BtlMenuTexBlockEnter();
1769 MenuCharaFace = TexManager.GetTexture("charaface", BtlMenuExReadBlock);
1770 BtStatus = TexManager.GetTexture("btstatus2", BtlMenuExReadBlock);
1771 NonCharaFace = TexManager.GetTexture("nonchara", BtlMenuExReadBlock);
1772 BtlAlpha = TexManager.GetTexture("alphabet", BtlMenuExReadBlock);
1773 BtlHira = TexManager.GetTexture("hira", BtlMenuExReadBlock);
1774 BtlKata = TexManager.GetTexture("kata", BtlMenuExReadBlock);
1775#ifdef PAL
1776 BtlEuro = TexManager.GetTexture("euro", BtlMenuExReadBlock);
1777#endif
1778 BtlMenuExReadFlag = 1;
1779 } else {
1780 return 1;
1781 }
1782 }
1783
1784 int done = ToFromSelect(0);
1785
1786 if (BtlMenuExReadFlag != 0) {
1787 MenuChara.timer += 1.0f;
1788 }
1789
1790 if (!(MenuChara.timer < 20.0f)) {
1791 MenuChara.timer = 20.0f;
1792 }
1793
1794 if (!(MenuChara.timer < 20.0f) && done == 1 && BtlMenuExReadFlag != 0) {
1795 MenuCharaMove = 0.0f;
1796 MenuChara.state = MENU_CHARA_SELECT;
1797 MenuChara.timer = 0.0f;
1798 BattleMenuFlag = BTLMENU_STATE_CHARA;
1799 }
1800
1801 break;
1802 }
1803 case MENU_CHARA_CLOSE: {
1804 int done = ToFromSelect(1);
1805 MenuChara.timer += 1.0f;
1806
1807 if (!(MenuChara.timer <= 20.0f) && done == 1) {
1808 ForBackMenu();
1809 int blocks[2] = {0, -1};
1810 blocks[0] = BtlMenuExReadBlock;
1811 MenuTextureDelete(blocks);
1812 TexManager.CleanUpTextureList();
1813 BtlMenuTexBlockEnter();
1814 MenuCharaFace = TexManager.GetTexture("charaface", BtlMenuReadBlock);
1815 BtStatus = TexManager.GetTexture("btstatus2", BtlMenuReadBlock);
1816 BattleMenuFlag = BTLMENU_STATE_MAIN;
1817 }
1818
1819 break;
1820 }
1821 case MENU_CHARA_TURN:
1822 MenuChara.timer += 1.0f;
1823
1824 if (!(MenuChara.timer < 21.0f)) {
1825 if (!(MenuCharaMove <= 0.0f)) {
1826 for (int i = 0; i < MenuChara.slot_count; i++) {
1827 SysChara[i].place++;
1828
1829 if (MenuChara.slot_count == SysChara[i].place) {
1830 SysChara[i].place = 0;
1831 }
1832 }
1833 } else {
1834 for (int i = 0; i < MenuChara.slot_count; i++) {
1835 SysChara[i].place--;
1836
1837 if (SysChara[i].place == -1) {
1838 SysChara[i].place = MenuChara.slot_count - 1;
1839 }
1840 }
1841 }
1842
1843 for (int i = 0; i < 6; i++) {
1844 if (SysChara[i].place == 0) {
1845 int chara = SysChara[i].chara;
1846 int mes_no = chara + 0x1E;
1847
1848 if (BtlMenuStatusPt->party_size - 1 < chara) {
1849 mes_no = 0x27;
1850 }
1851
1852 if (CommonMenuMes2.mes_made != mes_no) {
1853 CommonMenuMes2.MakeMesWin(mes_no);
1854 }
1855 }
1856 }
1857
1858 MenuChara.state = MENU_CHARA_SELECT;
1859 MenuChara.timer = 0.0f;
1860 MenuCharaMove = 0.0f;
1861 }
1862
1863 break;
1864 case MENU_CHARA_MESSAGE:
1865 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
1866 MenuChara.state = MENU_CHARA_SELECT;
1867 ComMenuSePlay(MENU_SOUND_CONFIRM);
1868 }
1869
1870 break;
1871 case MENU_CHARA_SELECT: {
1872 int old = MenuChara.chara;
1873
1874 if (GamePad.On(PAD_UP | PAD_RIGHT) != 0) {
1875 MenuCharaMove = PosAngle / 20.0f;
1876 MenuChara.state = MENU_CHARA_TURN;
1877 MenuChara.timer = 0.0f;
1878 MenuChara.chara--;
1879
1880 if (MenuChara.chara < 0) {
1881 MenuChara.chara = 5;
1882 }
1883
1884 ComMenuSePlay(MENU_SOUND_CURSOR);
1885 } else if (GamePad.On(PAD_DOWN | PAD_LEFT) != 0) {
1886 MenuCharaMove = -PosAngle / 20.0f;
1887 MenuChara.state = MENU_CHARA_TURN;
1888 MenuChara.timer = 0.0f;
1889 MenuChara.chara++;
1890
1891 if (MenuChara.chara > 5) {
1892 MenuChara.chara = 0;
1893 }
1894
1895 ComMenuSePlay(MENU_SOUND_CURSOR);
1896 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
1897 BattleMenuFlag = BTLMENU_STATE_CHARA_CLOSE;
1898 MenuChara.state = MENU_CHARA_CLOSE;
1899 MenuChara.timer = 0.0f;
1900 BtlEffectFlag = BTLEFFECT_PAGE_CLOSE;
1901 BtlEffectCt = 0;
1902 ComMenuSePlay(MENU_SOUND_REFUSE);
1903 } else if (GamePad.Down(PAD_CROSS) != 0) {
1904 switch (BtlMenuMode) {
1905 case BATTLE_MENU_MODE_DUNGEON: {
1906 int i;
1907 CDngStatusData *status = BtlMenuStatusPt;
1908 s8 cur;
1909 char *active = &status->cur_chara;
1910 cur = *active;
1911
1912 if (cur == CHARA_OSMOND && BtActStatus.ground_kind == 10) {
1913 CommonMenuMes1.MakeMesWin(0x1A1);
1914 ComMenuSePlay(MENU_SOUND_REFUSE);
1915 } else {
1916 for (i = 0; i < MenuChara.slot_count; i++) {
1917 if (SysChara[i].place != 0) {
1918 continue;
1919 }
1920
1921 int chara = SysChara[i].chara;
1922
1923 if (status->party_size - 1 < chara) {
1924 ComMenuSePlay(MENU_SOUND_REFUSE);
1925 return 1;
1926 }
1927
1928 s16 hp = status->hp[chara];
1929 int condition = status->GetActiveCharaStatus(chara);
1930
1931 if (hp <= 0 || (condition & AILMENT_KNOCKED_OUT)) {
1932 ComMenuSePlay(MENU_SOUND_REFUSE);
1933 return 1;
1934 }
1935
1936 if (chara != (s8) cur) {
1937 *active = chara;
1938 ComMenuSePlay(MENU_SOUND_CONFIRM);
1939 MenuChara.state = MENU_CHARA_CHANGE_LOAD;
1940 MenuChara.change_counter = 0;
1941 return 1;
1942 }
1943 }
1944 }
1945
1946 break;
1947 }
1948 default:
1949 ComMenuSePlay(MENU_SOUND_REFUSE);
1950 break;
1951 }
1952 }
1953
1954 if (old != MenuChara.chara && MenuChara.chara < BtlMenuStatusPt->party_size && BtlMenuCharaChangeBuf != NULL && BtlMenuMode == BATTLE_MENU_MODE_DUNGEON) {
1955 BreakReadBG();
1956 CharaChangeInitToGL(BtlMenuCharaChangeBuf, MenuChara.chara);
1957 }
1958
1959#ifdef PAL
1960 // Debug builds raise the front party member's maximum life and add or remove party members.
1961 if (DebugMode) {
1962 if (GamePad.On(PAD_R2 | PAD_R1) != 0) {
1963 for (int i = 0; i < MenuChara.slot_count; i++) {
1964 if (SysChara[i].place == 0) {
1965 int raised = BtlMenuStatusPt->max_hp[i] + 1;
1966
1967 if (raised < 0x80) {
1968 BtlMenuStatusPt->max_hp[i] = raised;
1969 }
1970 }
1971 }
1972 }
1973
1974 if (GamePad.Down2(PAD_CROSS) != 0 && BtlMenuStatusPt->party_size < 6) {
1975 BtlMenuStatusPt->party_size++;
1976 BtlMenuStatusPt->GetItem(GetDefaultWeaponNo(BtlMenuStatusPt->party_size - 1) + 1, 0);
1977 int chara = BtlMenuStatusPt->party_size - 1;
1978 BtlMenuStatusPt->equipped_weapon_slot[chara] = 0;
1979 EquipDefaultWeapon(BtlMenuStatusPt->party_size - 1);
1980 NameDefaultSet(BtlMenuStatusPt->party_size - 1);
1981 }
1982
1983 if (GamePad.Down2(PAD_CIRCLE) != 0 && BtlMenuStatusPt->party_size > 1) {
1984 BtlMenuStatusPt->party_size--;
1985 }
1986 }
1987
1988#endif
1989 break;
1990 }
1991 }
1992
1993 return 1;
1994}
1995
1996#pragma opt_propagation reset
1997
1998void DrawCharaSelect() {
1999 if (BtlMenuExReadFlag == 0) {
2000 return;
2001 }
2002
2003 int bright = 0x80;
2004 int ring_alpha = 0x80;
2005 int status_alpha;
2006 int face_alpha;
2007 int panel_alpha;
2008
2009 switch (MenuChara.state) {
2010 case MENU_CHARA_OPEN:
2011 bright = (int) (10.0f * MenuChara.timer);
2012 ring_alpha = bright;
2013 break;
2014 case MENU_CHARA_CLOSE:
2015 bright = (int) (128.0f - 12.0f * MenuChara.timer);
2016 ring_alpha = bright;
2017 break;
2018 case MENU_CHARA_CHANGE_LOAD:
2019 case MENU_CHARA_CHANGE_EXIT:
2020 bright = 0x80 - MenuChara.change_counter * 3;
2021 ring_alpha = 0x80 - MenuChara.change_counter * 10;
2022 break;
2023 }
2024
2025 if (ring_alpha > 0x80) {
2026 ring_alpha = 0x80;
2027 }
2028
2029 if (ring_alpha < 0) {
2030 ring_alpha = 0;
2031 }
2032
2033 if (bright < 0) {
2034 bright = 0;
2035 }
2036
2037 MenuTextureReload(BtlMenuExReadBlock);
2038 sceGsAlpha blend = mgAlpha;
2039 blend.bits.a = 0;
2040 blend.bits.b = 2;
2041 blend.bits.c = 0;
2042 blend.bits.d = 1;
2043 MGSetGsALPHA(&blend);
2044 DrawMenu2DSprite(TexManager.GetTexture("dgring", -1), CRect_i_(0x12A, 0x32, 0x118, 0x118), CRect_i_(0, 0, 0x80, 0x80), (ring_alpha * 0x8C) >> 7);
2045 MGSetGsALPHA(NULL);
2046
2047 switch (MenuChara.state) {
2048 case MENU_CHARA_OPEN:
2049 for (int i = 0; i < MenuChara.slot_count; i++) {
2050 float radius = chara_r_long / 20.0f * MenuChara.timer;
2051 float angle = PI + (PosAngle * (SysChara[i].place - 1.0f) + PosAngle / 20.0f * MenuChara.timer);
2052 SysChara[i].x = radius * cosf(angle);
2053 SysChara[i].y = radius * sinf(angle);
2054 }
2055
2056 break;
2057 case MENU_CHARA_TURN:
2058 for (int i = 0; i < MenuChara.slot_count; i++) {
2059 float radius = chara_r_long;
2060 float angle = PI + (PosAngle * SysChara[i].place + MenuCharaMove * MenuChara.timer);
2061 SysChara[i].x = radius * cos(angle);
2062 SysChara[i].y = radius * sin(angle);
2063 }
2064
2065 break;
2066 case MENU_CHARA_CHANGE_EXIT:
2067 case MENU_CHARA_CHANGE_LOAD:
2068 chara_r_long += MenuChara.change_counter;
2069
2070 for (int i = 0; i < MenuChara.slot_count; i++) {
2071 float radius = chara_r_long;
2072 float angle = PI + (PosAngle * SysChara[i].place + MenuCharaMove * MenuChara.change_counter);
2073 SysChara[i].x = radius * cos(angle);
2074 SysChara[i].y = radius * sin(angle);
2075 }
2076
2077 break;
2078 }
2079
2080 float size;
2081 float draw_x;
2082 float move;
2083 float face_x;
2084 float time;
2085 float grow;
2086 float face_y;
2087
2088 for (int i = 0; i < MenuChara.slot_count; i++) {
2089 face_x = 394.0f + SysChara[i].x;
2090 draw_x = face_x;
2091 face_y = 120.0f + SysChara[i].y;
2092 size = 90.0f;
2093 face_alpha = bright;
2094 status_alpha = bright;
2095 panel_alpha = 0;
2096
2097 if ((!((move = MenuCharaMove) <= 0.0f) && MenuChara.slot_count - 1 == SysChara[i].place) || (move < 0.0f && SysChara[i].place == 1)) {
2098 float step = 0.6666667f * MenuChara.timer;
2099 draw_x = face_x - step;
2100 size += step;
2101 panel_alpha = (int) (128.0f * MenuChara.timer / 21.0f);
2102 status_alpha = 0x80 - panel_alpha;
2103 }
2104
2105 if (SysChara[i].place == 0) {
2106 time = MenuChara.timer;
2107 float scale = 0.6666667f;
2108 draw_x = face_x + scale * (time - 20.0f - 1.0f);
2109 grow = scale * time;
2110 size = 106.0f - grow;
2111 status_alpha = (int) ((float) bright * time / 21.0f);
2112
2113 if (move == 0.0f) {
2114 face_alpha = 0x80;
2115 panel_alpha = 0x80;
2116 } else if (MenuChara.state == MENU_CHARA_TURN) {
2117 panel_alpha = (int) (128.0f - 10.0f * time);
2118 }
2119
2120 switch (MenuChara.state) {
2121 case MENU_CHARA_CHANGE_EXIT:
2122 case MENU_CHARA_CHANGE_LOAD:
2123 case MENU_CHARA_OPEN:
2124 case MENU_CHARA_CLOSE:
2125 size += grow;
2126 draw_x -= grow;
2127 status_alpha = 0;
2128 face_alpha = bright;
2129 panel_alpha = bright;
2130 break;
2131 }
2132 }
2133
2134 if (i < BtlMenuStatusPt->party_size) {
2135 float box_x = 23.0f + face_x;
2136 float box_y = 86.0f + face_y;
2137
2138 if (status_alpha > 0x80) {
2139 status_alpha = 0x80;
2140 }
2141
2142 if (status_alpha < 0) {
2143 status_alpha = 0;
2144 }
2145
2146 DrawOtherCharaStatus((int) box_x, (int) box_y, i, status_alpha);
2147 box_x = 394.0f + SysChara[i].x - 29.0f;
2148 box_y = 120.0f + SysChara[i].y - 3.0f;
2149
2150 if (panel_alpha > 0x80) {
2151 panel_alpha = 0x80;
2152 }
2153
2154 if (panel_alpha < 0) {
2155 panel_alpha = 0;
2156 }
2157
2158#ifdef PAL
2159 if (box_x < -300.0f || (float) 0x28A < box_x || face_y < -130.0f || 1280.0f < face_y) {
2160#else
2161 if (box_x < -300.0f || (float) 0x28A < box_x || face_y < -130.0f || 448.0f < face_y) {
2162#endif
2163 continue;
2164 }
2165
2166 MenuTextureReload(BtlMenuExReadBlock);
2167 DrawSelCharaStatus(box_x, box_y, i, panel_alpha, (int) size, face_alpha, (int) draw_x, (int) face_y);
2168 }
2169
2170 MenuTextureReload(BtlMenuExReadBlock);
2171 CTexture *face = MenuCharaFace;
2172 int u = 0;
2173 int v;
2174 int width = 0x6A;
2175 v = i * 0x6A;
2176
2177 if (i > 2) {
2178 u = 0x6A;
2179 v = (i - 3) * 0x6A;
2180 }
2181
2182 int shade = 0x80;
2183 s16 hp = BtlMenuStatusPt->hp[i];
2184 int condition = BtlMenuStatusPt->GetActiveCharaStatus(i);
2185
2186 if (hp <= 0 || (condition & AILMENT_KNOCKED_OUT)) {
2187 shade = 0x50;
2188 }
2189
2190 if (BtlMenuStatusPt->party_size <= i) {
2191 face = NonCharaFace;
2192
2193 if (SysChara[i].place == 0) {
2194 face = TexManager.GetTexture("nonchara2", -1);
2195 v = 0xC;
2196 u = 0xC;
2197 width = 0x6A;
2198 } else {
2199 v = 0x13;
2200 u = 0x13;
2201 width = 0x5A;
2202 size -= 1.0f;
2203 }
2204
2205 shade = 0x80;
2206 }
2207
2208 if (face_alpha > 0x80) {
2209 face_alpha = 0x80;
2210 }
2211
2212 if (face_alpha < 0) {
2213 face_alpha = 0;
2214 }
2215
2216 if (MenuChara.state == MENU_CHARA_CHANGE_EXIT || MenuChara.state == MENU_CHARA_CHANGE_LOAD) {
2217 face_alpha = 0x80 - MenuChara.change_counter * 2;
2218
2219 if (face_alpha < 0) {
2220 face_alpha = 0;
2221 }
2222 }
2223
2224 if (0.0f < draw_x && draw_x < 640.0f && 0.0f < face_y && face_y < SCREEN_HEIGHT_F) {
2225 DrawMenu2DSprite(face, CRect_i_((int) draw_x, (int) face_y, (int) size, (int) size), CRect_i_(u, v, width, width), shade, shade, shade, face_alpha);
2226 }
2227 }
2228
2229 CommonMenuMes1.auto_pos = MES_POS_NONE;
2230 CommonMenuMes1.stay_frame = false;
2231
2232 switch (MenuChara.state) {
2233 case MENU_CHARA_MESSAGE:
2234 AllFadeForMenu(0x40);
2235 CommonMenuMes1.auto_pos = MES_POS_CENTRE;
2236 CommonMenuMes1.stay_frame = true;
2237 CommonMenuMes1.Step();
2238 CommonMenuMes1.DrawMesWin();
2239 break;
2240 case MENU_CHARA_OPEN:
2241 case MENU_CHARA_CLOSE:
2242 case MENU_CHARA_CHANGE_LOAD:
2243 case MENU_CHARA_CHANGE_EXIT:
2244 break;
2245 default: {
2246 float angle = PI;
2247 float waku_x = 394.0f + chara_r_long * cosf(angle) - 184.0f;
2248 face_y = 120.0f + chara_r_long * sinf(angle) - 26.0f;
2249 int width = 0x102;
2250 int cursor_x = 0x3C;
2251 int i;
2252
2253 for (i = 0; i < 6; i++) {
2254 if (SysChara[i].place == 0) {
2255 break;
2256 }
2257 }
2258
2259 if (BtlMenuStatusPt->party_size <= SysChara[i].chara) {
2260 cursor_x = 0xA0;
2261 waku_x = (float) (0x18A + chara_r_long * cos(angle) - 30.0);
2262 width = 0x6E;
2263 }
2264
2265 SysCur[0] += ((float) cursor_x - SysCur[0]) / 4.0f;
2266 int draw_x = (int) SysCur[0];
2267 DrawMenuWaku(waku_x, face_y, width, 0x82, 1, StayTex, 0x80);
2268 DrawMenuObjectVibe(draw_x, (int) SysCur[1], 1, 0x40);
2269 break;
2270 }
2271 }
2272}
2273
2274void DrawWepDamageDraw(RECT rect, WEAPON_HAVE *weapon, int alpha) {
2275 int x = rect.x;
2276 int max_exp;
2277 int exp;
2278 int y = rect.y;
2279 int durability = weapon->durability;
2280 int now = GetDispVolumeForFloat(weapon->durability_f);
2281 max_exp = GetWeaponMaxExp(weapon);
2282 exp = weapon->experience;
2283
2284 if (max_exp < exp) {
2285 exp = max_exp;
2286 }
2287
2288 if (exp < 0) {
2289 exp = 0;
2290 }
2291
2292 if (max_exp <= 0) {
2293 max_exp = 99;
2294 }
2295
2296 int exp_len = exp * 99 / max_exp;
2297 DrawMenu2DSprite(WepStatus, CRect_i_(rect.x, y, durability, 8), CRect_i_(0x100, 0x70, 8, 8), alpha);
2298 static int warningcnt = 0;
2299 warningcnt++;
2300
2301 if (weapon->durability_f <= 0.1f * weapon->durability || max_exp == exp) {
2302 abs((int) (60.0f * sinf((float) warningcnt / 18.0f)));
2303 warningcnt++;
2304
2305 if (warningcnt > 1000000) {
2306 warningcnt = 0;
2307 }
2308 }
2309
2310 MGFillBox(CRect_i_(rect.x * 16, ((y - 1) >> 1) * 16, (durability + 1) * 16, 0x50), 0x4F, 0x4F, 0x4F, alpha);
2311 GRADATION_COLOR_INFO2 colours;
2312 memcpy(&colours, GetGradationColorInfo2(25), sizeof(colours));
2313 colours.colors[3].a = alpha;
2314 colours.colors[2].a = alpha;
2315 colours.colors[1].a = alpha;
2316 colours.colors[0].a = alpha;
2317 DrawMenuColorGradation(CRect_i_(rect.x, y, now, 8), &colours.colors[0], &colours.colors[1], &colours.colors[2], &colours.colors[3]);
2318 y += rect.height;
2319 RECT digits = {0xD4, 0x1F4, 0xC, 0xD};
2320 x += rect.width;
2321 DrawMenuNumber(durability, x, y, WepStatus, digits, 1, alpha);
2322 DrawMenu2DSprite(WepStatus, CRect_i_(x - 0x20, y, 0xC, 0xB), CRect_i_(digits.x + 0x78, digits.y, 0xC, 0xC), alpha);
2323 DrawMenuNumber(now, x - 0x20, y, WepStatus, digits, 1, alpha);
2324 rect.y += 0x14;
2325 y = rect.y;
2326 DrawMenu2DSprite(WepStatus, CRect_i_(rect.x, y, exp_len, 8), CRect_i_(0x100, 0x78, 8, 8), alpha);
2327 int digits_count = GetNumberKeta(max_exp);
2328 x = rect.x;
2329 y += rect.height;
2330 x += digits_count * 0x18;
2331 DrawMenuNumber(max_exp, x, y, WepStatus, digits, 1, alpha);
2332 x -= digits_count * 0x10;
2333 DrawMenu2DSprite(WepStatus, CRect_i_(x, y, 0xC, 0xB), CRect_i_(digits.x + 0x78, digits.y, 0xC, 0xC), alpha);
2334 DrawMenuNumber(exp, x, y, WepStatus, digits, 1, alpha);
2335}
2336
2337void DrawWepStatus(int x, int y, WEAPON_HAVE *weapon, int selected, int alpha) {
2338 int v = 0;
2339
2340 if (selected != 0) {
2341 v += 0x34;
2342 }
2343
2344 DrawMenu2DSprite(WepStatus, CRect_i_(x, y + 1, 0xAC, 0x33), CRect_i_(0xD4, v, 0xAC, 0x34), alpha);
2345 RECT rect = {0, 0, 0x30, -7};
2346 rect.x = x + 0x3E;
2347 rect.y = y + 0xF;
2348 DrawWepDamageDraw(rect, weapon, alpha);
2349}
2350
2351void DrawWepVolumeDisplay(int x, int y, WEAPON_HAVE *weapon, int alpha) {
2352 WEAPON_DATA *data = GetWeaponData(weapon->item_no);
2353
2354 if (data == NULL) {
2355 return;
2356 }
2357
2358 WEAPON_HAVE total;
2359 WeaponAllValueSet(weapon, &total, 0);
2360 CRect_i_ source(0x110, 0xCC, 0x10, 0x10);
2361 CRect_i_ dest(x, y, source.width, source.height);
2362 RECT digits = {0xD4, 0x1F4, 0xC, 0xD};
2363
2364 if (weapon->best_elem < 5) {
2365#ifdef PAL
2366 // The face sheet lives in the main block and WepStatus in the extension block; each is made resident before use.
2367 MenuTextureReload(BtlMenuReadBlock);
2368#endif
2369 DrawMenu2DSprite(MenuCharaFace, CRect_i_(x, y - 0x10, 0x20, 0x10), CRect_i_(0xE0, weapon->best_elem * 16, 0x20, 0x10), alpha);
2370#ifdef PAL
2371 MenuTextureReload(BtlMenuExtBlock);
2372#endif
2373 }
2374
2375 int values[4] = {0, 0, 0, 0};
2376 values[0] = total.attack;
2377 values[1] = total.endurance;
2378 values[2] = total.speed;
2379 values[3] = total.magic;
2380 float rate = GetNowWeaponRate(&total);
2381 int limit[4] = {data->attack_max, 99, 99, data->magic_max};
2382 limit[0] = (int) ((float) limit[0] * rate);
2383 limit[3] = (int) ((float) limit[3] * rate);
2384
2385 for (int i = 0; i < 4; i++, dest.y += source.height, source.y += source.height) {
2386 if (limit[i] < values[i]) {
2387 values[i] = limit[i];
2388 }
2389
2390 DrawMenu2DSprite(WepStatus, dest, source, alpha);
2391 DrawMenuNumber(values[i], dest.x + source.width + digits.width * 3 - 2, dest.y + 2, WepStatus, digits, 1, alpha);
2392 }
2393}
2394
2402static void DrawWeaponNameBoard(int x, int y, int width, int alpha, int brightness) {
2403 CRect_i_ left(x, y + 1, 0x28, 0x1F);
2404 CRect_i_ middle(x + 0x28, y + 1, 0x99, 0x1F);
2405 CRect_i_ right(x + 0xAC, y + 1, 0x20, 0x1F);
2406
2407 DrawMenu2DSprite(WepStatus, left, CRect_i_(0xE0, 0x1A8, 0x28, 0x20), brightness, brightness, brightness, alpha);
2408 DrawMenu2DSprite(WepStatus, middle, CRect_i_(0x108, 0x1A8, 0x78, 0x20), brightness, brightness, brightness, alpha);
2409 DrawMenu2DSprite(WepStatus, right, CRect_i_(0xD4, 0x1D4, 0x20, 0x20), brightness, brightness, brightness, alpha);
2410}
2411
2412s32 GetWeaponNamePutX(s32 center_x, s32 width) {
2413 return center_x - (width >> 1);
2414}
2415
2419static inline void SetLinePos(ClsMes *window, int line, int x, int y) {
2420 if (line >= 0 && line < 10) {
2421 window->line_pos[line].x = x;
2422 window->line_pos[line].y = y;
2423 }
2424}
2425
2437static void WeaponNameDraw(int y, int selected_only, int alpha) {
2438 int previous_mes[4];
2439 int previous_level[4];
2440
2441 MenuTextureReload(AtoraNameMes.tex_block);
2442 int slot = WepMenu.weapon_slot - 1;
2443
2444 for (int i = 0; i < 4; i++) {
2445 previous_mes[i] = AtoraNameMes.mes_no[i];
2446 previous_level[i] = AtoraNameMes.values[i];
2447 }
2448
2449 int x = 22.0f + WeaponPos + slot * 0xD6;
2450 AtoraNameMes.value_signed = true;
2451
2452 for (int i = 0; i < 3; i++) {
2453 int mes_no;
2454 int level = 0;
2455
2456 if (x < -140 || x > 630 || (selected_only == 1 && slot != WepMenu.weapon_slot) || slot < 0 || slot > 9 || ((WepMenu.state == WEP_STATE_STATUS_BREAK_EFFECT || WepMenu.state == WEP_STATE_BUILDUP_EFFECT) && slot == WepMenu.weapon_slot) || (WepMenu.mode > WEP_MENU_LIST && slot != WepMenu.weapon_slot) || (WepMenu.state != WEP_STATE_REPAIR_EFFECT && WepMenu.state >= WEP_STATE_STATUS_BREAK_EFFECT && WepMenu.state < WEP_STATE_WARNING) || (WepMenu.state == WEP_STATE_LEVELUP_EFFECT && slot != WepMenu.weapon_slot)) {
2457 mes_no = 999;
2458 } else {
2459 mes_no = GetWeaponMsgNo(&DngWepHavePt[slot]);
2460
2461 if (mes_no < 0 || slot < 0) {
2462 mes_no = 999;
2463 }
2464
2465 if (mes_no > 100) {
2466 AtoraNameMes.GetMesWidth_system(mes_no);
2467 level = DngWepHavePt[slot].level;
2468 }
2469 }
2470
2471 int width = AtoraNameMes.GetMesWidth_system(mes_no);
2472 AtoraNameMes.mes_no[i] = mes_no;
2473 AtoraNameMes.values[i] = level;
2474 int name_x = GetWeaponNamePutX(x + 0x42, width);
2475
2476 if (level > 0) {
2477 name_x -= 8;
2478
2479 if (level / 10 > 0) {
2480 name_x -= 8;
2481 }
2482 }
2483
2484 SetLinePos(&AtoraNameMes, i, name_x, y);
2485 x += 0xD6;
2486 slot++;
2487 }
2488
2489 for (int i = 0; i < 4; i++) {
2490 if (AtoraNameMes.line_pos[i].y > 180) {
2491 AtoraNameMes.line_pos[i].y = y;
2492 AtoraNameMes.mes_no[i] = 999;
2493 }
2494 }
2495
2496 for (int i = 0; i < 4; i++) {
2497 if (AtoraNameMes.mes_no[i] != previous_mes[i] || AtoraNameMes.values[i] != previous_level[i]) {
2498 AtoraNameMes.mes_made = -1;
2499 AtoraNameMes.MakeMesWin(150);
2500 break;
2501 }
2502 }
2503
2504 AtoraNameMes.edge_alpha = alpha;
2505 AtoraNameMes.Step();
2506 AtoraNameMes.DrawMesWin();
2507
2508 if (WepMenu.mode == WEP_MENU_LIST && WepMenu.state == WEP_STATE_IDLE) {
2509 CTexture *frame = TexManager.GetTexture("frame_image", -1);
2510
2511 if (frame != NULL) {
2512 TexManager.ReloadTexture(GetVif1Packet(), frame->block);
2513 ((sceGsTex0 *) &frame->tex0)->bits.tcc = 0;
2514 sceGsTexa texa = mgTexa;
2515 texa.AEM = 1;
2516 texa.TA0 = 0x80;
2517 MGSetGsTEXA(&texa);
2518 CRect_i_ rect(0, 0x14A, 0x104, 0x76);
2519 set2DSprite(GetVif1Packet(), frame, rect, rect, 0x40, 0x40, 0x40, alpha);
2520 MGSetGsTEXA(NULL);
2521 }
2522 }
2523}
2524
2525RECT WeaponVolumeNumberRect = {212, 500, 12, 13};
2526
2534static void WepStatusVolumeDraw(RECT rect, int width, int *volume, int color, int alpha, int build, int gain) {
2535 int y = rect.y;
2536 int fill = (float) (volume[1] * width) / (float) volume[0];
2537
2538 if (fill > width) {
2539 fill = width;
2540 }
2541
2542 GRADATION_COLOR_INFO2 gradation;
2543 memcpy(&gradation, GetGradationColorInfo2(color), sizeof(gradation));
2544 gradation.colors[3].a = alpha;
2545 gradation.colors[2].a = alpha;
2546 gradation.colors[1].a = alpha;
2547 gradation.colors[0].a = alpha;
2548 CRect_i_ bar(rect.x, y, fill, 8);
2549 DrawMenuColorGradation(bar, &gradation.colors[0], &gradation.colors[1], &gradation.colors[2], &gradation.colors[3]);
2550 fill = (float) (volume[2] * width) / (float) volume[0];
2551
2552 if (fill > width) {
2553 fill = width;
2554 }
2555
2556 int number_alpha = 1.5f * alpha;
2557
2558 if (build == 1 && gain > 0) {
2559 DrawMenuNumber(volume[1], rect.x + rect.width, y + rect.height, WeaponVolumeNumberRect, WepStatus, 2, 0xDC, 0, 0, alpha);
2560 } else {
2561 DrawMenuNumber(volume[1], rect.x + rect.width, y + rect.height, WepStatus, WeaponVolumeNumberRect, 2, alpha);
2562 }
2563}
2564
2565void DrawWeaponStatusWaku(int x, int y, int width, int limit) {
2566 spRGBA colours[2][2] = {
2567 {{0x3B, 0x68, 0x56, 0x80}, {0x3B, 0x68, 0x56, 0x80}},
2568 {{0x00, 0x00, 0xE6, 0x80}, {0x00, 0x00, 0xE6, 0x80}}
2569 };
2570 CRect_i_ rect(x - 1, y - 1, width + 2, 10);
2571 DrawMenuSideGradation(rect, &colours[limit][0], &colours[limit][1]);
2572}
2573
2581static void DrawLimmitMax(int x, int y, int alpha) {
2582 DrawMenu2DSprite(WepStatus, CRect_i_(x, y, 0x1E, 0xA), CRect_i_(0xF8, 0x158, 0x1E, 0xA), alpha);
2583}
2584
2585void DrawBtlMenuLRCursor(int x, int y, int width, int alpha) {
2586 int count = CursorVibeCnt % 79;
2587 double pi = PI;
2588 int draw_y = (int) ((float) y + 4.0f * sinf((float) (pi * ((double) count - 40.0) / 40.0)));
2589 CRect_i_ source(0x62, 0x14, 0x1A, 0x18);
2590 DrawMenu2DSprite(PerBoardTex, CRect_i_(x, draw_y, source.width, source.height), source, alpha);
2591 source.x += source.width;
2592 DrawMenu2DSprite(PerBoardTex, CRect_i_(x + width, draw_y, source.width, source.height), source, alpha);
2593}
2594
2595void DrawWeaponStatusTag(int x, int y, WEAPON_HAVE *weapon, int build, int weapon_no, int alpha) {
2596 WEAPON_DATA *built = NULL;
2597
2598 if (build == 1) {
2599 built = GetWeaponData(weapon_no);
2600 }
2601
2602 RECT pos = {0, 0, 0x1E, -8};
2603 pos.x = x + 0x4B;
2604 pos.y = y + 0x30;
2605 s16 gauge[2] = {0, 0};
2606 int number_x;
2607 int bar_y;
2608 float now = weapon->durability_f;
2609 gauge[0] = (int) now;
2610 int value = weapon->durability;
2611 gauge[1] = value;
2612 number_x = pos.x;
2613 bar_y = pos.y;
2614 int shown = (int) now;
2615
2616 if ((float) shown < now) {
2617 shown = (int) (1.0f + now);
2618 }
2619
2620 int full = value * 0x7E / 99;
2621 int fill = shown * full / value;
2622
2623 if (fill >= 0x7E) {
2624 fill = 0x7E;
2625 }
2626
2627 MGFillBox(CRect_i_(pos.x * 16, (bar_y >> 1) * 16, full * 16, 0x40), 0x4F, 0x4F, 0x4F, alpha);
2628 GRADATION_COLOR_INFO2 colours;
2629 memcpy(&colours, GetGradationColorInfo2(25), sizeof(colours));
2630 colours.colors[3].a = alpha;
2631 colours.colors[2].a = alpha;
2632 colours.colors[1].a = alpha;
2633 colours.colors[0].a = alpha;
2634 DrawMenuColorGradation(CRect_i_(pos.x, bar_y, fill, 8), &colours.colors[0], &colours.colors[1], &colours.colors[2], &colours.colors[3]);
2635 bar_y += pos.height;
2636
2637 for (int digits = GetNumberKeta(value) - 1; digits > 0; digits--) {
2638 int width = pos.width;
2639 number_x += width;
2640 }
2641
2642 DrawMenuNumber(weapon->durability, number_x, bar_y, WepStatus, WeaponVolumeNumberRect, 1, alpha);
2643 DrawMenu2DSprite(WepStatus, CRect_i_(number_x - 0x20, bar_y, 0xC, 0xB), CRect_i_(WeaponVolumeNumberRect.x + 0x78, WeaponVolumeNumberRect.y, 0xC, 0xC), alpha);
2644 DrawMenuNumber(shown, number_x - 0x20, bar_y, WepStatus, WeaponVolumeNumberRect, 1, alpha);
2645 pos.y += 0x18;
2646 number_x = pos.x;
2647 bar_y = pos.y;
2648 int max_exp = GetWeaponMaxExp(weapon);
2649 int exp_len = (weapon->experience << 7) / max_exp;
2650
2651 if (exp_len > 0x7E) {
2652 exp_len = 0x7E;
2653 }
2654
2655 DrawMenu2DSprite(WepStatus, CRect_i_(pos.x, bar_y, exp_len, 8), CRect_i_(0x100, 0x78, 8, 8), alpha);
2656 bar_y += pos.height;
2657
2658 for (int digits = GetNumberKeta(max_exp); digits >= 2; digits--) {
2659 number_x += WeaponVolumeNumberRect.width * 2;
2660 }
2661
2662 int left = DrawMenuNumber(max_exp, number_x, bar_y, WepStatus, WeaponVolumeNumberRect, 1, alpha);
2663 DrawMenu2DSprite(WepStatus, CRect_i_(left - 0xB, bar_y, 0xC, 0xB), CRect_i_(WeaponVolumeNumberRect.x + 0x78, WeaponVolumeNumberRect.y, 0xC, 0xC), alpha);
2664 DrawMenuNumber(weapon->experience, left - 0xB, bar_y, WepStatus, WeaponVolumeNumberRect, 2, alpha);
2665 int values[4] = {0, 0, 0, 0};
2666 values[0] = weapon->attack;
2667 values[1] = weapon->endurance;
2668 values[2] = weapon->speed;
2669 values[3] = weapon->magic;
2670 int bonus[4] = {0, 0, 0, 0};
2671 int target[4] = {0, 0, 0, 0};
2672
2673 if (build == 1 && built != NULL) {
2674 target[0] = built->attack;
2675 target[1] = built->endurance;
2676 target[2] = built->speed;
2677 target[3] = built->magic;
2678 }
2679
2680 WEAPON_DATA *data = GetWeaponData(weapon->item_no);
2681 int limit[4] = {data->attack_max, 99, 99, data->magic_max};
2682
2683 if (build == 0) {
2684 for (int i = 0; i < 4; i++) {
2685 bonus[i] = GetWeaponAttachStatusUp(weapon, i + 1);
2686
2687 if (bonus[i] < 0) {
2688 bonus[i] = 0;
2689 }
2690 }
2691 }
2692
2693 float rate = GetNowWeaponRate(weapon);
2694
2695 if (build == 1) {
2696 rate = 1.0f;
2697 }
2698
2699 if (!(rate <= 1.0f)) {
2700 limit[0] = (int) ((float) limit[0] * rate);
2701 limit[3] = (int) ((float) limit[3] * rate);
2702 }
2703
2704 RECT row = {0, 0, -4, -2};
2705 row.x = x + 0x4A;
2706 row.y = y + 0x60;
2707 int volume[3] = {0, 0, 0};
2708 volume[0] = 100;
2709
2710 for (int i = 0; i < 4; i++) {
2711 int limited = 0;
2712 value = values[i];
2713 volume[1] = value + bonus[i];
2714 volume[1] = (int) ((float) volume[1] * rate);
2715
2716 if (volume[1] >= limit[i]) {
2717 volume[1] = limit[i];
2718 limited = 1;
2719 }
2720
2721 volume[2] = value;
2722
2723 if (volume[2] >= limit[i]) {
2724 volume[2] = limit[i];
2725 }
2726
2727 int length = (int) ((float) (volume[1] << 7) / (float) volume[0]);
2728
2729 if (length > 0x80) {
2730 length = 0x80;
2731 }
2732
2733 int diff = target[i] - value;
2734 DrawWeaponStatusWaku(row.x, row.y, length, limited);
2735 WepStatusVolumeDraw(row, 0x80, volume, i + 3, alpha, build, diff);
2736
2737 if (limited != 0) {
2738 DrawLimmitMax(row.x + 4, row.y + 3, 0x80);
2739 }
2740
2741 row.y += 0x10;
2742 }
2743}
2744
2745void DrawWeaponElemTag(int x, int y, WEAPON_HAVE *weapon, int build, int weapon_no, int alpha) {
2746 WEAPON_DATA *built = NULL;
2747
2748 if (build == 1) {
2749 built = GetWeaponData(weapon_no);
2750 }
2751
2752 int best = weapon->best_elem;
2753
2754 if (best < 5) {
2755 int src_y = best * 0x18 + 0x68;
2756 int tag_y = y + 0x24 + best * 0x18;
2757 DrawMenu2DSprite(WepStatus, CRect_i_(x + 6, tag_y + 1, 0x2C, 0x18), CRect_i_(0xD4, src_y, 0x2C, 0x18), alpha);
2758 }
2759
2760 RECT row = {0, 0, -4, -4};
2761 row.x = x + 0x4A;
2762 row.y = y + 0x30;
2763 float rate = GetNowWeaponRate(weapon);
2764 int bonus[5] = {0, 0, 0, 0, 0};
2765 int target[5] = {0, 0, 0, 0, 0};
2766
2767 if (build == 0) {
2768 for (int i = 0; i < 5; i++) {
2769 bonus[i] = GetWeaponAttachStatusUp(weapon, i + 8);
2770 }
2771 }
2772
2773 if (build == 1 && built != NULL) {
2774 for (int i = 0; i < 5; i++) {
2775 target[i] = built->elem[i];
2776 }
2777 }
2778
2779 int volume[3] = {0, 0, 0};
2780 volume[0] = 100;
2781
2782 for (int i = 0; i < 5; i++) {
2783 int limited = 0;
2784 volume[1] = weapon->elem[i] + bonus[i];
2785 volume[1] = (int) ((float) volume[1] * rate);
2786
2787 if (volume[1] >= 99) {
2788 volume[1] = 99;
2789 limited = 1;
2790 }
2791
2792 volume[2] = weapon->elem[i];
2793
2794 if (volume[2] >= 99) {
2795 volume[2] = 99;
2796 }
2797
2798 float length = (float) (volume[1] << 7) / (float) volume[0];
2799 int width = (int) length;
2800 DrawWeaponStatusWaku(row.x, row.y, (int) length, limited);
2801 int diff = target[i] - weapon->elem[i];
2802 WepStatusVolumeDraw(row, 0x80, volume, i + 7, alpha, build, diff);
2803
2804 if (limited != 0) {
2805 DrawLimmitMax(row.x + 2, row.y + 4, 0x80);
2806 }
2807
2808 row.y += 0x18;
2809 }
2810
2811 if (best < 5) {
2812 int mark_y = y + 0x30 + best * 0x18;
2813 DrawMenu2DSprite(WepStatus, CRect_i_(x + 0x8A, mark_y, 0x42, 0x15), CRect_i_(0xD4, 0x190, 0x42, 0x16), (alpha * 0x6E) >> 7);
2814 }
2815}
2816
2817void DrawWeaponVsMonster(int x, int y, WEAPON_HAVE *weapon, int build, int weapon_no, int alpha) {
2818 WEAPON_DATA *built = NULL;
2819
2820 if (build == 1) {
2821 built = GetWeaponData(weapon_no);
2822 }
2823
2824 int top = y + 0x30;
2825 RECT row = {0, 0, 0x10, -8};
2826 row.x = x + 0x22;
2827 row.y = top;
2828 int volume[3] = {100, 0, 0};
2829 int bonus[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
2830 int target[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
2831
2832 if (build == 0) {
2833 for (int i = 0; i < 10; i++) {
2834 bonus[i] = GetWeaponAttachStatusUp(weapon, i + 14);
2835 }
2836 }
2837
2838 if (build == 1) {
2839 for (int i = 0; i < 10; i++) {
2840 target[i] = built->vs_monster[i];
2841 }
2842 }
2843
2844 float rate = GetNowWeaponRate(weapon);
2845
2846 for (int i = 0; i < 10; i++) {
2847 int limited = 0;
2848 volume[1] = weapon->vs_monster[i] + bonus[i];
2849 volume[1] = (int) ((float) volume[1] * rate);
2850
2851 if (volume[1] >= 99) {
2852 limited = 1;
2853 volume[1] = 99;
2854 }
2855
2856 volume[2] = weapon->vs_monster[i];
2857
2858 if (volume[2] >= 99) {
2859 volume[2] = 99;
2860 }
2861
2862 float length = (float) (volume[1] << 6) / (float) volume[0];
2863 int width = (int) length;
2864 DrawWeaponStatusWaku(row.x, row.y, (int) length, limited);
2865 int diff = target[i] - weapon->vs_monster[i];
2866 WepStatusVolumeDraw(row, 0x40, volume, i + 12, alpha, build, diff);
2867
2868 if (limited != 0) {
2869 DrawLimmitMax(row.x + 0x1E, row.y + 4, 0x80);
2870 }
2871
2872 row.y += 0x18;
2873
2874 if (i == 4) {
2875 row.x = x + 0x8A;
2876 row.y = top;
2877 }
2878 }
2879}
2880
2888static void DrawWeaponTagBoard(int x, int y, WEAPON_HAVE *weapon, int build, int weapon_no, int alpha) {
2889 int page = WepMenu.tag_page;
2890 int tag = 0;
2891 int i = 0;
2892 int step = 1;
2893 int wrapped = 0;
2894
2895 for (; i < 3; i++) {
2896 int brightness = 128;
2897
2898 if (page == tag) {
2899 if (wrapped != 0) {
2900 tag = page;
2901 } else {
2902 tag = 2;
2903 step = -1;
2904 wrapped = 1;
2905 }
2906 }
2907
2908 if (WepMenu.mode == WEP_MENU_ELEMENT && tag != WEP_TAG_ELEMENT) {
2909 brightness = 64;
2910 }
2911
2912 int top = tag * 0xAA;
2913 DrawMenu2DSprite(WepStatus, CRect_i_(x, y, 0xD4, 0xAA), CRect_i_(0, top, 0xD4, 0xAA), brightness, brightness, brightness, alpha);
2914 tag += step;
2915 }
2916
2917 if (weapon != NULL) {
2918 switch (page) {
2919 case WEP_TAG_STATUS:
2920 DrawWeaponStatusTag(x, y, weapon, build, weapon_no, alpha);
2921 break;
2922 case WEP_TAG_ELEMENT:
2923 DrawWeaponElemTag(x, y, weapon, build, weapon_no, alpha);
2924 break;
2925 case WEP_TAG_VS_MONSTER:
2926 DrawWeaponVsMonster(x, y, weapon, build, weapon_no, alpha);
2927 break;
2928 }
2929 }
2930}
2931
2932void DrawAallWeapon(int x, int y, float depth, CCharacter *model, WEAPON_HAVE *weapon, int equipped, int selected, int alpha) {
2933 if (weapon == NULL) {
2934 return;
2935 }
2936
2937 MenuTextureReload(MenuExtendReadBlock);
2938 int draw_x;
2939 float spin = 0.0f;
2940 sceVu0FVECTOR position = {0.0f, -1.3f, 0.0f, 1.0f};
2941 position[0] = depth;
2942
2943 if (model != NULL) {
2944 if (equipped != 0) {
2945 position[1] = -1.3f + sinf(WepFrameRate);
2946 WepFrameRate += 0.34906587f;
2947 float limit = PI;
2948
2949 if (limit <= WepFrameRate) {
2950 WepFrameRate = limit;
2951 }
2952
2953 if (PI != WepFrameRate) {
2954 spin = 0.0f;
2955 }
2956 }
2957
2958 MENU_WEP_POLY_OFFSET *offset = &MenuWepPolyOffset[WepMenu.chara];
2959 position[0] += offset->position[0];
2960 position[1] += offset->position[1];
2961 model->SetPosition(position);
2962 float scale = offset->scale;
2963 model->SetScale(scale, scale, scale);
2964
2965 if (selected != 0) {
2966 spin = (float) (PI_D * (CursorVibeCnt % 219 - 110) / 110);
2967 }
2968
2969 if (MenuWepLevelUp.operation_kind == WEP_EFFECT_NONE || MenuWepLevelUp.operation_kind == WEP_EFFECT_RECOVER || MenuWepLevelUp.operation_kind == WEP_EFFECT_BUILDUP) {
2970 float rot_x = -HALF_PI;
2971
2972 if (rot_x > PI_D) {
2973 rot_x -= PI;
2974 }
2975
2976 float rot_y = 0.0f;
2977 spin = rot_y + spin;
2978
2979 if (spin > PI_D) {
2980 spin -= PI;
2981 }
2982
2983 float rot_z = 0.62831855f;
2984
2985 if (rot_z > PI_D) {
2986 rot_z -= PI;
2987 }
2988
2989 model->SetRotation(rot_x, spin, rot_z);
2990 }
2991
2992 model->Draw();
2993 }
2994
2995#ifdef PAL
2996 MenuTextureReload(BtlMenuExtBlock);
2997
2998#else
2999 MenuTextureReload(BtlMenuReadBlock);
3000
3001#endif
3002 switch (WepMenu.mode) {
3003 case WEP_MENU_LIST:
3004 case WEP_MENU_ACTION:
3005 case WEP_MENU_ELEMENT:
3006 case WEP_MENU_LEVELUP_CONFIRM:
3007 case WEP_MENU_STATUS_BREAK_CONFIRM:
3008 case WEP_MENU_BUILDUP_SELECT:
3009 case WEP_MENU_BUILDUP_CONFIRM:
3010 case WEP_MENU_BUILDUP_PREVIEW:
3011 draw_x = x + 2;
3012 DrawWepStatus(draw_x, y + 0x66, weapon, equipped, alpha);
3013 DrawWepVolumeDisplay(x, y + 0x14, weapon, alpha);
3014 break;
3015 case WEP_MENU_ATTACH_WEAPON:
3016 case WEP_MENU_ATTACH_SOCKETS:
3017 case WEP_MENU_ATTACH_BOARD:
3018 case WEP_MENU_ATTACH_TAGS:
3019 break;
3020 }
3021
3022 DrawWeaponNameBoard(x - 0x11, y - 0x32, equipped, alpha, 0x80);
3023
3024 if (equipped != 0) {
3025 DrawMenu2DSprite(WepStatus, CRect_i_(x + 10, y - 0x15, 0x40, 0x17), CRect_i_(0xD4, 0x141, 0x40, 0x17), alpha);
3026 }
3027
3028 WeaponStarDraw(x + 4, y + 0x3C, weapon, alpha);
3029
3030 if (selected != 0) {
3031 MenuMes.draw_x = x + 0xBE;
3032 MenuMes.draw_y = y + 0xE;
3033 } else {
3034 MenuMes.draw_x = 0x280;
3035 MenuMes.draw_y = 0;
3036 WeaponOptionStatusDraw(weapon, x + 0x50, y - 0x12, alpha);
3037 }
3038
3039 if (selected != 0) {
3040 MenuMes.draw_x = x + 0xA0;
3041 MenuMes.draw_y = y + 0xE;
3042 } else {
3043 WeaponOptionStatusDraw(weapon, x + 0x50, y - 0x12, alpha);
3044 }
3045
3046 float hole_scale[2] = {0.75f, 1.0f};
3047 float width = GetWeaponHoleNum(weapon->item_no) * 0x12 + 10;
3048 width *= hole_scale[selected];
3049 draw_x = (int) ((float) (x + 0x52) - width);
3050
3051 if (WepMenu.mode >= WEP_MENU_ATTACH_WEAPON) {
3052 DrawWepHole(draw_x, 0xB8, weapon, selected, alpha);
3053 MenuTextureReload(MenuShadowReadBlock);
3054 DrawWepAttach(draw_x + 0xE, 0xBE, weapon, selected, alpha);
3055 }
3056}
3057
3058void BtlWeaponDraw(int x, float depth, int chara, int alpha) {
3059 int equipped_slot = BtlMenuStatusPt->equipped_weapon_slot[chara];
3060 int cursor = WepMenu.weapon_slot;
3061 sceVu0FVECTOR ref = {0.0f, 0.0f, -45.0f, 1.0f};
3062 sceVu0FVECTOR pos = {0.0f, 0.0f, 60.0f, 1.0f};
3063 sceVu0FVECTOR ambient;
3064 sceVu0FVECTOR bright;
3065 sceVu0FMATRIX light_dir;
3066 sceVu0FMATRIX light_col;
3067
3068 MenuCamera.SetRef(ref);
3069 MenuCamera.SetPos(pos);
3070 MGGetPLight(light_dir, light_col);
3071 MGGetAmbient(ambient);
3072 bright[0] = bright[1] = bright[2] = 80.0f;
3073 sceVu0FVECTOR direction = {0.3f, 1.0f, 0.3f, 0.0f};
3074 sceVu0FVECTOR normal;
3075 sceVu0Normalize(normal, direction);
3076 sceVu0FMATRIX dir = {
3077 {0.3f, 0.0f, 0.0f, 0.0f},
3078 {0.3f, 0.0f, 0.0f, 0.0f},
3079 {0.3f, 0.0f, 0.0f, 0.0f},
3080 {0.0f, 0.0f, 0.0f, 0.0f}
3081 };
3082 sceVu0FMATRIX col = {
3083 {96.0f, 96.0f, 96.0f, 0.0f},
3084 {0.0f, 0.0f, 0.0f, 0.0f},
3085 {0.0f, 0.0f, 0.0f, 0.0f},
3086 {0.0f, 0.0f, 0.0f, 0.0f}
3087 };
3088 dir[0][0] = normal[0];
3089 dir[1][0] = normal[1];
3090 dir[2][0] = normal[2];
3091 MGSetPLight(dir, col);
3092
3093 for (int i = 0; i < 10; i++, x += 0xD6, depth += 16.0f) {
3094 int draw_alpha = alpha;
3095
3096 if (x < -0x60 || (WepMenu.mode >= WEP_MENU_ATTACH_WEAPON && i != cursor)) {
3097 continue;
3098 }
3099
3100 if (x >= 0x277) {
3101 break;
3102 }
3103
3104 WEAPON_HAVE *weapon = &DngWepHavePt[i];
3105 int is_equipped = 0;
3106
3107 if (i == equipped_slot) {
3108 is_equipped = 1;
3109 }
3110
3111 int is_selected = 0;
3112
3113 if (i == cursor) {
3114 is_selected = 1;
3115 }
3116
3117 if (is_selected != 0) {
3118 switch (WepMenu.state) {
3119 case WEP_STATE_STATUS_BREAK_EFFECT:
3120 switch (MenuWepLevelUp.effect_state) {
3121 case WEP_EFFECT_STATE_BREAK_PLAY:
3122 draw_alpha = (int) (128.0f - 4.0f * MenuWepLevelUp.effect_timer);
3123
3124 if (draw_alpha < 0) {
3125 draw_alpha = 0;
3126 }
3127
3128 break;
3129 case WEP_EFFECT_STATE_BREAK_DONE:
3130 if (MenuWepLevelUp.lost_default_weapon != 0) {
3131 draw_alpha = 0;
3132 } else {
3133 draw_alpha = (int) MenuWepLevelUp.effect_timer;
3134 }
3135
3136 if (draw_alpha > 0x80) {
3137 draw_alpha = 0x80;
3138 }
3139
3140 break;
3141 }
3142
3143 break;
3144 }
3145
3146 MenuMes.alpha = draw_alpha;
3147 } else {
3148 if (WepMenu.mode > WEP_MENU_LIST) {
3149 draw_alpha = 0;
3150 continue;
3151 }
3152
3153 if (WepMenu.state >= WEP_STATE_LEVELUP_EFFECT) {
3154 draw_alpha = 0;
3155 continue;
3156 }
3157
3158 if (WepMenu.state >= WEP_STATE_LEVELUP_EFFECT && WepMenu.state < 15) {
3159 draw_alpha = 0;
3160 }
3161 }
3162
3163 bright[3] = draw_alpha;
3164 MGSetAmbient(bright);
3165
3166 if (MenuExTextureReadFlag != MENU_EX_TEX_READY) {
3167 continue;
3168 }
3169
3170 if (weapon->item_no >= ITEM_WEAPON_START) {
3171 CCharacter *frame = NULL;
3172
3173 switch (GetNowTestNo()) {
3174 case 1:
3175 if (is_equipped != 0) {
3176 MenuTextureReload(MenuShadowReadBlock);
3177 char *shadows[6] = {"kagetoan", "kagesyao", "kagegoro", "kageruby", "kageunga", "kageozu"};
3178 DrawMenu2DSprite(TexManager.GetTexture(shadows[WepMenu.chara], -1), CRect_i_(x + 0x24, 0x96, 0x64, 0x63), CRect_i_(0, 0, 0x64, 0x64), draw_alpha * 9 / 40);
3179 MenuTextureReload(MenuExtendReadBlock);
3180 }
3181
3182 int frame_no = GetMenuWeaponModelFrameNo(i);
3183
3184 if (frame_no >= 0) {
3185 frame = &DngWeaponFrm[frame_no];
3186 MenuWeaponSpSet(frame, weapon);
3187 }
3188
3189 break;
3190 }
3191
3192 if (frame != NULL) {
3193 DrawAallWeapon(x, 0xA0, depth, frame, weapon, is_equipped, is_selected, draw_alpha);
3194 }
3195 } else {
3196#ifdef PAL
3197 MenuTextureReload(BtlMenuExtBlock);
3198
3199#else
3200 MenuTextureReload(BtlMenuReadBlock);
3201
3202#endif
3203 if (is_selected == 0 || WepMenu.state != WEP_STATE_STATUS_BREAK_EFFECT) {
3204 DrawMenuNothing(x - 4, 0x82, 0xB4, 0x96, "wepstatus", 0, draw_alpha);
3205 }
3206 }
3207
3208 MenuMes.mode = MENU_CLSMES_OFF;
3209
3210 switch (WepMenu.mode) {
3211 case WEP_MENU_ATTACH_TAGS:
3212 case WEP_MENU_ATTACH_SOCKETS:
3213 case WEP_MENU_ATTACH_BOARD:
3214 case WEP_MENU_ATTACH_WEAPON:
3215 MenuTextureReload(BtlMenuReadBlock);
3216 DrawBtlMenuLRCursor(x - 0x1C, 0xE6, 0xD4, draw_alpha);
3217#ifdef PAL
3218 MenuTextureReload(BtlMenuExtBlock);
3219#endif
3220 DrawWeaponTagBoard(x - 0xC, 0xF0, weapon, 0, 0, draw_alpha);
3221 case WEP_MENU_LIST:
3222 WeaponOptionStatusDraw(weapon, x + 0x50, 0x8E, draw_alpha);
3223 break;
3224 default:
3225 MenuMes.mode = MENU_CLSMES_OPTIONS;
3226 break;
3227 }
3228 }
3229
3230 MGSetPLight(light_dir, light_col);
3231 MGSetAmbient(ambient);
3232
3233 if (MenuExTextureReadFlag == MENU_EX_TEX_READY) {
3234 int tags = 0;
3235
3236 switch (WepMenu.mode) {
3237 case WEP_MENU_ATTACH_TAGS:
3238 case WEP_MENU_ATTACH_WEAPON:
3239 case WEP_MENU_ATTACH_SOCKETS:
3240 case WEP_MENU_ATTACH_BOARD:
3241 tags = 1;
3242 break;
3243 }
3244
3245 WeaponNameDraw(0x72, tags, alpha);
3246 }
3247
3248 switch (WepMenu.mode) {
3249 case WEP_MENU_ATTACH_TAGS:
3250 case WEP_MENU_ATTACH_SOCKETS:
3251 case WEP_MENU_ATTACH_BOARD:
3252 case WEP_MENU_ATTACH_WEAPON:
3253 break;
3254 default: {
3255 int dim = 0;
3256
3257 if (WepMenu.mode != WEP_MENU_LIST) {
3258 dim = 1;
3259 }
3260
3261 FadeTexX(0, 0xCC, 0x1AE, 0xD2, "frame_image", dim);
3262 break;
3263 }
3264 }
3265
3266 if (WepMenu.state != WEP_STATE_STATUS_BREAK_EFFECT) {
3267 MenuMes.Step();
3268 MenuMes.Draw1(MenuMes.draw_x, MenuMes.draw_y, MenuMes.alpha);
3269 }
3270}
3271
3279static int NowWeaponStatusValue(WEAPON_HAVE *weapon) {
3280 if (weapon == NULL) {
3281 return 0;
3282 }
3283
3284 int status = 0;
3285
3286 if (weapon->experience >= GetWeaponMaxExp(weapon) || GetNowItemNum(ITEM_POWERUP_POWDER, MenuItemPackPt) > 0) {
3287 status |= 2;
3288 }
3289
3290 if (WeaponStatusBreakEnable(weapon) != 0) {
3291 status |= 4;
3292 }
3293
3294 status |= 8;
3295 int build_up = 0;
3296
3297 if (WeaponStatusBuildUp(weapon, build_up) > 0 && GetNowWeaponAttachNum(weapon) == 0 && build_up > 0) {
3298 status |= 0x10;
3299 }
3300
3301 if (IsNotBuildUpWeapon(weapon->item_no) != 0) {
3302 if (status & 8) {
3303 status &= ~8;
3304 }
3305
3306 if (status & 0x10) {
3307 status &= ~0x10;
3308 }
3309 }
3310
3311 return status;
3312}
3313
3317static int EnableWeaponElemNone(int weapon_no) {
3318 if (WhoIsWeaponEquip(weapon_no) == CHARA_RUBY) {
3319 return 1;
3320 }
3321
3322 if ((unsigned int) (weapon_no - ITEM_WEAPON_BLESSING_GUN) <= 1U || weapon_no == ITEM_WEAPON_HEXA_BLASTER || weapon_no == ITEM_WEAPON_SUPERNOVA) {
3323 return 2;
3324 }
3325
3326 return 0;
3327}
3328
3336static void WeaponMenuCheckElemValue(WEAPON_HAVE *weapon, WEAPON_HAVE *attachment) {
3337 if (0 <= weapon->best_elem && weapon->best_elem < 5 && attachment->elem[weapon->best_elem] <= 0) {
3338 weapon->best_elem = 5;
3339 }
3340
3341 if (weapon->best_elem == 5 && EnableWeaponElemNone(weapon->item_no) != 0) {
3342 SetWeaponElementStatus(weapon);
3343 }
3344
3345 printf("now active elem = %d\n", weapon->best_elem);
3346 printf("now active vol = %d\n", weapon->elem[weapon->best_elem]);
3347}
3348
3356static int WeaponMenuCheckEnableSetElem(WEAPON_HAVE *weapon, WEAPON_HAVE *attachment, int elem) {
3357 int refused = 0;
3358
3359 if (weapon->best_elem == elem) {
3360 if (EnableWeaponElemNone(weapon->item_no) != 0) {
3361 WepMenu.state = WEP_STATE_WARNING;
3362 WepMenu.warning_no = 9;
3363 refused = 1;
3364 } else {
3365 weapon->best_elem = 5;
3366 }
3367 } else if (attachment->elem[elem] > 0) {
3368 weapon->best_elem = elem;
3369 } else {
3370 WepMenu.state = WEP_STATE_WARNING;
3371 WepMenu.warning_no = 0;
3372 refused = 1;
3373 }
3374
3375 if (weapon != NULL) {
3376 printf("now elem = %d\n", weapon->best_elem);
3377
3378 if (weapon->best_elem != 5) {
3379 printf("now elem vol = %d\n", attachment->elem[weapon->best_elem]);
3380 }
3381 }
3382
3383 return refused;
3384}
3385
3386void DrawWeaponSelectDialog(int x, int y, int alpha) {
3387 s8 shift = 0;
3388
3389 if (BtlMenuNowLang > LANG_JAPANESE) {
3390 shift = 2;
3391 }
3392
3393 int left = x + shift;
3394 int top = y + shift;
3395 int bright;
3396 WEAPON_HAVE *weapon = GetNowSelectWeapon();
3397 int repair_items = GetNowItemNum(ITEM_REPAIR_POWDER, MenuItemPackPt);
3398 int options = NowWeaponStatusValue(weapon);
3399 int title_v = 0x68;
3400
3401 switch (WepMenu.state) {
3402 case WEP_STATE_EQUIP:
3403 title_v += 0xA0;
3404 break;
3405 }
3406
3407 DrawMenu2DSprite(WepStatus, CRect_i_(left, top + 1, 0x60, 0x1F), CRect_i_(0x120, title_v, 0x60, 0x20), alpha);
3408 CRect_i_ source(0x120, 0x88, 0x60, 0x20);
3409 DrawMenu2DSprite(WepStatus, CRect_i_(left, top + 0x1B, 0x60, 0x1F), source, alpha);
3410 source.y += 0x20;
3411 int build_x = left;
3412
3413 if (WepMenu.mode == WEP_MENU_ELEMENT) {
3414 build_x = left + 0x28;
3415 }
3416
3417 DrawMenu2DSprite(WepStatus, CRect_i_(build_x, top + 0x35, 0x60, 0x1F), CRect_i_(0x120, 0x148, 0x60, 0x20), alpha);
3418 bright = 0x80;
3419
3420 if (repair_items <= 0 || weapon->durability_f == (float) weapon->durability) {
3421 bright = 0x40;
3422 }
3423
3424 static int warmcnt = 0;
3425 int default_no = GetDefaultWeaponNo(WepMenu.chara);
3426
3427 if ((weapon->durability_f <= 0.1f * weapon->durability || weapon->item_no == default_no) && repair_items > 0) {
3428 bright = abs((int) (50.0f * sinf((float) warmcnt / 12.0f))) + 0x78;
3429 warmcnt++;
3430
3431 if (warmcnt > 1000000) {
3432 warmcnt = 0;
3433 }
3434 }
3435
3436 DrawMenu2DSprite(WepStatus, CRect_i_(left, top + 0x4F, 0x60, 0x1F), source, bright, bright, bright, alpha);
3437 source.y += 0x20;
3438 static int levelbrinkcnt = 0;
3439 int level_bright = 0x80;
3440 levelbrinkcnt++;
3441
3442 if (levelbrinkcnt > 1000000) {
3443 levelbrinkcnt = 0;
3444 }
3445
3446 CRect_i_ dest(left, top + 0x69, 0x60, 0x1F);
3447
3448 for (int i = 1; i <= 3; i++) {
3449 if (options & (1 << i)) {
3450 DrawMenu2DSprite(WepStatus, dest, source, level_bright, level_bright, level_bright, alpha);
3451 dest.y += 0x1A;
3452 }
3453
3454 source.y += 0x20;
3455
3456 if (i == 2) {
3457 source.y += 0x20;
3458 int build = 0;
3459 WeaponStatusBuildUp(weapon, build);
3460 int attached = GetNowWeaponAttachNum(weapon);
3461
3462 if (build > 0 && attached == 0) {
3463 level_bright += abs((int) (40.0f * sinf((float) levelbrinkcnt / 12.0f)));
3464 }
3465 }
3466 }
3467
3468 switch (WepMenu.state) {
3469 case WEP_STATE_SCRAP_PROMPT:
3470 case WEP_STATE_SCRAP_CONFIRM:
3471 DrawMenu2DSprite(BtStatus, CRect_i_(x + 0x64, y + 0x33, 0x60, 0x1F), CRect_i_(0, 0x80, 0x60, 0x20), 0x80);
3472 break;
3473 }
3474}
3475
3483static void InitWeaponSelect(int mode, int chara) {
3484 InitPersonalBoardMode((CUserStatus *) BtlMenuStatusPt, &WepMenu.board, PERSONAL_BOARD_WEAPON_ATTACH, BOARD_PAGE_ATTACH);
3485 WepMenu.open_mode = mode;
3486 WepMenu.mode = WEP_MENU_LIST;
3487 WepMenu.chara = chara;
3488
3489 switch (mode) {
3490 case WEP_OPEN_FROM_BAR:
3491 WepMenu.state = WEP_STATE_OPEN;
3492 BtlHaveItemPt = &WepMenu.board.held_item;
3493 break;
3494 case WEP_OPEN_IN_PLACE:
3495 WepMenu.state = WEP_STATE_IDLE;
3496 break;
3497 case WEP_OPEN_VIEW_ONLY:
3498 break;
3499 }
3500
3501 WepMenu.counter = 0;
3502 StartReadWepMDS(BtlMenuReadBuf, chara);
3503 MenuExTextureReadFlag = MENU_EX_TEX_UNREAD;
3504 CDngStatusData *status = BtlMenuStatusPt;
3505 DngWepHavePt = status->chara_weapons[chara];
3506
3507 for (int i = 0; i < 10; i++) {
3508 if (DngWepHavePt[i].item_no < ITEM_WEAPON_START) {
3509 memset(&DngWepHavePt[i], 0, sizeof(WEAPON_HAVE));
3510 DngWepHavePt[i].item_no = -1;
3511 }
3512 }
3513
3514 WepMenu.weapon_slot = BtlMenuStatusPt->equipped_weapon_slot[chara];
3515
3516 if (WepMenu.weapon_slot < 0 || WepMenu.weapon_slot >= 10) {
3517 WepMenu.weapon_slot = 0;
3518 }
3519
3520 SysCur[0] = 235.0f;
3521 SysCur[1] = 165.0f;
3522 WepMenu.chara = chara;
3523
3524 for (int i = 0; i < 6; i++) {
3525 SysChara[i].x = (SysChara[i].chara - WepMenu.chara) * 110 + 270;
3526 SysChara[i].y = 14.0f;
3527 }
3528
3529 WeaponPos = 0xE8 - WepMenu.weapon_slot * 0xD6;
3530 WepPolyPos = 2.0f + 16.0f * -WepMenu.weapon_slot;
3531 WepFrameRate = PI;
3532 WepMenu.warning_no = -1;
3533 MenuWepLevelUp.buildup_complete = 0;
3534 CommonMenuMes3.Preset(MES_PRESET_SYSTEM);
3535 CommonMenuMes3.char_width = GetMenuCommonFontW(BtlMenuNowLang, -1);
3536 CommonMenuMes3.style = MES_EDGE_NONE;
3537 AtoraNameMes.value_show = false;
3538 AtoraNameMes.value_narrow = false;
3539 AtoraNameMes.char_width = GetMenuCommonFontW(BtlMenuNowLang, -1);
3540 AtoraNameMes.style = MES_EDGE_NONE;
3541 AtoraNameMes.narrow_gaiji = true;
3542 memset(AtoraNameMes.tex_buff, 0, 0x100);
3543
3544 for (int i = 0; i < 10; i++) {
3545 AtoraNameMes.mes_no[i] = -1;
3546 AtoraNameMes.values[i] = 0;
3547 }
3548
3549 AtoraNameMes.columns = 16;
3550 AtoraNameMes.Preset(MES_PRESET_NAME);
3551 AtoraNameMes.mes_made = -1;
3552 MenuMes.InitData();
3553 MenuMes.message->unk_02C = 0x10;
3554 MenuMes.message->init_030 = 0x10;
3555}
3556
3564static void ExitWeaponMenuSelect() {
3565 int chara = BtlMenuStatusPt->cur_chara;
3566
3567 if (BtlMenuMode == BATTLE_MENU_MODE_DUNGEON && chara == WepMenu.chara) {
3568 DngWeaponEquipModelBuild(chara, MenuExtendReadBlock, BtlMenuReadBuf);
3569 }
3570
3571 TexManager.DeleteTextureBlock(MenuExtendReadBlock);
3572 TexManager.CleanUpTextureList();
3573 BtlMenuTexBlockEnter();
3574 BattleMenuFlag = BTLMENU_STATE_WEAPON_CLOSE;
3575 CommonMenuMes3.text_columns = MES_WIN_COLUMNS;
3576 CommonMenuMes3.text_rows = 10;
3577 CommonMenuMes3.text_len = 0;
3578 CommonMenuMes3.text_width = 0;
3579 CommonMenuMes3.text_height = 0;
3580 CommonMenuMes3.fade = 0.0f;
3581 CommonMenuMes3.fade_in = true;
3582 CommonMenuMes3.text_rate = CommonMenuMes3.text_rate_set;
3583 CommonMenuMes3.waiting = false;
3584 CommonMenuMes3.text_at = 0.0f;
3585 CommonMenuMes3.text_no = 0;
3586 CommonMenuMes3.text_from = 0;
3587 CommonMenuMes3.page_from = 0;
3588 CommonMenuMes3.InitMesWinTbl();
3589 CommonMenuMes3.clut_now = CommonMenuMes3.clut_default;
3590 CommonMenuMes3.wait = 0;
3591 CommonMenuMes3.blink = 0;
3592 CommonMenuMes3.auto_page_wait = 0;
3593 CommonMenuMes3.mes_made = -1;
3594 CommonMenuMes3.edge_alpha = 128;
3595
3596 for (int slot = 0; slot < 10; slot++) {
3597 CommonMenuMes3.mes_no[slot] = -1;
3598 }
3599
3600 for (int slot = 0; slot < 8; slot++) {
3601 CommonMenuMes3.values[slot] = 0;
3602 }
3603
3604 CommonMenuMes3.value = 0;
3605 CommonMenuMes3.value_signed = false;
3606 CommonMenuMes3.value_show = true;
3607 CommonMenuMes3.value_narrow = false;
3608 CommonMenuMes3.space_width = -1;
3609 CommonMenuMes3.space_area = -1;
3610 CommonMenuMes3.cursor_row = -1;
3611 CommonMenuMes3.cursor_y = 0;
3612 CommonMenuMes3.cursor_lit = false;
3613
3614 for (int line = 0; line < 10; line++) {
3615 CommonMenuMes3.line_pos[line].x = -1;
3616 CommonMenuMes3.line_pos[line].y = -1;
3617 }
3618
3619 CommonMenuMes3.Preset(MES_PRESET_SYSTEM);
3620 CommonMenuMes3.char_width = GetMenuCommonFontW(BtlMenuNowLang, -1);
3621 CommonMenuMes3.char_height = 22;
3622 CommonMenuMes3.value_narrow = false;
3623 AtoraNameMes.value_show = true;
3624 AtoraNameMes.value_narrow = false;
3625 AtoraNameMes.narrow_gaiji = false;
3626 AtoraNameMes.char_width = GetMenuCommonFontW(BtlMenuNowLang, -1);
3627 CommonMenuMes1.value_narrow = false;
3628 ForBackMenu();
3629 BattleMenuFlag = BTLMENU_STATE_MAIN;
3630}
3631
3632void WeaponMenuSelect() {
3633 int direction = -1;
3634
3635 switch (WepMenu.state) {
3636 case WEP_STATE_OPEN:
3637 direction = 0;
3638 break;
3639 case WEP_STATE_CLOSE:
3640 direction = 1;
3641 break;
3642 }
3643
3644 int done = ToFromSelect(direction);
3645
3646 switch (MenuExTextureReadFlag) {
3647 case MENU_EX_TEX_UNREAD:
3648 if (MenuWepLevelUp.buildup_complete == 0) {
3649 if (ReadBGSync() == 0) {
3650 if (MenuExTextureReadFlag != MENU_EX_TEX_UNREAD) {
3651 break;
3652 }
3653
3654 MenuExTextureReadFlag = EnterWeaponModel(WepMenu.chara, MenuExtendReadBlock, WepMenu.weapon_slot);
3655 BtlMenuTexBlockEnter();
3656 BtlMDSBuildCnt = 0;
3657 WepMenu.counter = 0;
3658 } else {
3659 return;
3660 }
3661 }
3662
3663 if (MenuWepLevelUp.buildup_complete == 1) {
3664 WeaponModelBuildFunc(WepMenu.chara, MenuExtendReadBlock);
3665 BtlMDSBuildCnt = 0;
3666 MenuWepLevelUp.buildup_complete = 0;
3667 MenuExTextureReadFlag++;
3668 }
3669
3670 break;
3671 case MENU_EX_TEX_BUILDING:
3672 BtlMDSBuildCnt++;
3673
3674 if (BtlMDSBuildCnt > 3) {
3675 MenuExTextureReadFlag = MENU_EX_TEX_READY;
3676 }
3677
3678 break;
3679 }
3680
3681 if (WepMenu.state != WEP_STATE_IDLE) {
3682 WepMenu.counter++;
3683 } else {
3684 WepMenu.counter = 0;
3685 }
3686
3687 switch (WepMenu.state) {
3688 case WEP_STATE_OPEN:
3689 if (!((float) WepMenu.counter <= 18.0f) && done != 0 && MenuExTextureReadFlag != MENU_EX_TEX_UNREAD) {
3690 BattleMenuFlag = BTLMENU_STATE_WEAPON;
3691 WepMenu.state = WEP_STATE_IDLE;
3692 WepMenu.counter = 0;
3693 }
3694
3695 break;
3696 case WEP_STATE_CLOSE:
3697 if (WepMenu.counter > 20 && done != 0) {
3698 ExitWeaponMenuSelect();
3699 }
3700
3701 break;
3702 case WEP_STATE_LEVELUP_EFFECT:
3703 case WEP_STATE_STATUS_BREAK_EFFECT:
3704 case WEP_STATE_BUILDUP_EFFECT:
3705 case WEP_STATE_REPAIR_EFFECT:
3706 if (MenuWepLevelUp.effect_active == 0 && GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0 && (MenuWepLevelUp.effect_state == WEP_EFFECT_STATE_BREAK_DONE || MenuWepLevelUp.effect_state == WEP_EFFECT_STATE_LEVELUP_DONE || MenuWepLevelUp.effect_state == WEP_EFFECT_STATE_BUILDUP_DONE || MenuWepLevelUp.effect_state == WEP_EFFECT_STATE_RECOVER_DONE)) {
3707 WEAPON_HAVE *weapon = MenuWepLevelUp.weapon;
3708
3709 switch (WepMenu.state) {
3710 case WEP_STATE_LEVELUP_EFFECT:
3711 MenuWepLevelUp.SetLevelUpWeaponData();
3712 weapon->level++;
3713 weapon->synthesis_count += MenuWepLevelUp.synthesis_count;
3714
3715 for (int i = 0; i < 6; i++) {
3716 memset(&weapon->attach[i], 0, sizeof(weapon->attach[i]));
3717 }
3718
3719 break;
3720 case WEP_STATE_STATUS_BREAK_EFFECT: {
3721 int equipped = BtlMenuStatusPt->GetEquipWeaponSlot(WepMenu.chara);
3722
3723 if (WepMenu.weapon_slot == equipped || DngWepHavePt[equipped].item_no < ITEM_WEAPON_START) {
3724 EquipDefaultWeapon(WepMenu.chara);
3725 }
3726
3727 MenuWepLevelUp.lost_default_weapon = false;
3728 break;
3729 }
3730 case WEP_STATE_BUILDUP_EFFECT:
3731 case WEP_STATE_REPAIR_EFFECT:
3732 break;
3733 }
3734
3735 if (WepMenu.state != WEP_STATE_REPAIR_EFFECT) {
3736 MenuWepLevelUp.SetSnd(MenuWepLevelUp.snd_volume, MenuWepLevelUp.snd_from, 7);
3737 }
3738
3739 MenuWepLevelUp.Initialize();
3740 WepMenu.state = WEP_STATE_IDLE;
3741 }
3742
3743 break;
3744 case WEP_STATE_WARNING:
3745 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
3746 WepMenu.state = WEP_STATE_IDLE;
3747 WepMenu.warning_no = -1;
3748 }
3749
3750 break;
3751 case WEP_STATE_SCRAP_REFUSED:
3752 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
3753 WepMenu.state = WEP_STATE_IDLE;
3754 }
3755
3756 break;
3757 case WEP_STATE_SCRAP_PROMPT:
3758 if (GamePad.Down(PAD_CROSS) != 0) {
3759 WEAPON_HAVE *weapon = GetNowSelectWeapon();
3760
3761 if (0 <= IsDefaultWeapon(weapon->item_no)) {
3762 ComMenuSePlay(MENU_SOUND_REFUSE);
3763 WepMenu.state = WEP_STATE_SCRAP_REFUSED;
3764 } else if (weapon->item_no == ITEM_WEAPON_SERPENT_SWORD && GetMenuHebikiriFlag() == 0) {
3765 WepMenu.state = WEP_STATE_SCRAP_REFUSED;
3766 ComMenuSePlay(MENU_SOUND_REFUSE);
3767 } else {
3768 WepMenu.state = WEP_STATE_SCRAP_CONFIRM;
3769 ComMenuSePlay(MENU_SOUND_CONFIRM);
3770 }
3771 } else if (GamePad.Down(PAD_CIRCLE | PAD_LEFT) != 0) {
3772 WepMenu.state = WEP_STATE_IDLE;
3773 ComMenuSePlay(MENU_SOUND_CURSOR);
3774 }
3775
3776 if (WepMenu.state == WEP_STATE_IDLE) {
3777 WepMenu.board.cursor = 0;
3778 }
3779
3780 break;
3781 case WEP_STATE_SCRAP_CONFIRM:
3782 if (GamePad.Down(PAD_UP | PAD_DOWN) != 0) {
3783 if (WepMenu.confirm[0] != 0) {
3784 WepMenu.confirm[0] = 0;
3785 } else {
3786 WepMenu.confirm[0] = 1;
3787 }
3788
3789 ComMenuSePlay(MENU_SOUND_CURSOR);
3790 }
3791
3792 if (GamePad.Down(PAD_CROSS) != 0) {
3793 if (WepMenu.confirm[0] == 0) {
3794 WEAPON_HAVE *weapon = GetNowSelectWeapon();
3795
3796 if (0 <= IsDefaultWeapon(weapon->item_no)) {
3797 ComMenuSePlay(MENU_SOUND_REFUSE);
3798 } else {
3799 InitHaveWep(weapon);
3800 ComMenuSePlay(MENU_SOUND_CONFIRM);
3801 WepMenu.state = WEP_STATE_IDLE;
3802
3803 if (WepMenu.weapon_slot == BtlMenuStatusPt->GetEquipWeaponSlot(WepMenu.chara)) {
3804 EquipDefaultWeapon(WepMenu.chara);
3805 }
3806
3807 ComMenuSePlay(MENU_SOUND_CONFIRM);
3808 }
3809 } else {
3810 WepMenu.state = WEP_STATE_IDLE;
3811 ComMenuSePlay(MENU_SOUND_REFUSE);
3812 }
3813 } else if (GamePad.Down(PAD_CIRCLE | PAD_LEFT) != 0) {
3814 WepMenu.state = WEP_STATE_IDLE;
3815 ComMenuSePlay(MENU_SOUND_CURSOR);
3816 }
3817
3818 if (WepMenu.state == WEP_STATE_IDLE) {
3819 WepMenu.board.cursor = 0;
3820 WepMenu.mode = WEP_MENU_LIST;
3821 }
3822
3823 break;
3824 case WEP_STATE_EQUIP:
3825 if (!(WepFrameRate < PI)) {
3826 WepMenu.state = WEP_STATE_IDLE;
3827 }
3828 case WEP_STATE_CHARA_CHANGE:
3829 if (WepMenu.counter >= 26) {
3830 WepMenu.state = WEP_STATE_IDLE;
3831 }
3832 case WEP_STATE_IDLE: {
3833 int slot;
3834 int cursor;
3835 int chara;
3836 int elem;
3837 int page;
3838 slot = WepMenu.weapon_slot;
3839 cursor = WepMenu.board.cursor;
3840 page = WepMenu.mode;
3841 chara = WepMenu.chara;
3842 elem = WepMenu.element;
3843
3844 switch (page) {
3845 case WEP_MENU_LIST:
3846 case WEP_MENU_ACTION:
3847 case WEP_MENU_ELEMENT:
3848 case WEP_MENU_LEVELUP_CONFIRM:
3849 case WEP_MENU_STATUS_BREAK_CONFIRM:
3850 case WEP_MENU_BUILDUP_SELECT:
3851 case WEP_MENU_BUILDUP_CONFIRM:
3852 case WEP_MENU_BUILDUP_PREVIEW:
3853 if (GetMenuCharaEffectReadFlag() != 0) {
3854 if (ReadBGSync() == 0) {
3855 SetMenuCharaEffectReadFlag(0);
3856 }
3857 } else {
3858 WeaponSelectKey();
3859 }
3860
3861 break;
3862 case WEP_MENU_ATTACH_WEAPON:
3863 case WEP_MENU_ATTACH_SOCKETS:
3864 case WEP_MENU_ATTACH_BOARD:
3865 case WEP_MENU_ATTACH_TAGS:
3866 WeaponMenuAttachModeKey();
3867 break;
3868 }
3869
3870 if (slot != WepMenu.weapon_slot || (page == WepMenu.mode && cursor != WepMenu.board.cursor) || chara != WepMenu.chara || elem != WepMenu.element) {
3871 ComMenuSePlay(MENU_SOUND_CURSOR);
3872 }
3873
3874 break;
3875 }
3876 }
3877
3878 int help_no = 0;
3879 int mes_no;
3880 int name_mes = -1;
3881 int name_no = -0x1F3;
3882 int value = 0;
3883 WEP_BUILDUP_INFO builds[4];
3884 ATTACH_LIST *attachments = (ATTACH_LIST *) ((CUserStatus *) BtlMenuStatusPt)->consumable_items;
3885 WEAPON_HAVE *weapon = &DngWepHavePt[WepMenu.weapon_slot];
3886
3887 if (weapon != NULL) {
3888 name_no = GetWeaponMsgNo2(weapon->item_no);
3889 }
3890
3891 s16 page_mes[12] = {0, 0, 0, 0, 0, 0, 0, 0xAC, 0x73, 0, 0, 0};
3892 page_mes[1] = WepMenu.board.cursor + 0x68;
3893 page_mes[2] = WepMenu.element + 0x82;
3894 int name_msg = name_no + 500;
3895 page_mes[3] = name_msg;
3896 page_mes[4] = name_msg;
3897 page_mes[5] = name_msg;
3898 page_mes[6] = name_msg;
3899 page_mes[11] = WepMenu.tag_row + ((WepMenu.tag_page + 2) * 10 + 100);
3900 mes_no = page_mes[WepMenu.mode];
3901
3902 if (WepMenu.mode >= WEP_MENU_LEVELUP_CONFIRM && WepMenu.mode < WEP_MENU_ATTACH_WEAPON) {
3903 s16 dialog[5] = {0x74, 0x76, 0x75, 0x77, 0x75};
3904 help_no = dialog[WepMenu.mode - WEP_MENU_LEVELUP_CONFIRM];
3905
3906 if (MenuWepLevelUp.operation_kind != WEP_EFFECT_NONE) {
3907 help_no = CommonMenuMes1.mes_made;
3908 }
3909 }
3910
3911 switch (WepMenu.mode) {
3912 case WEP_MENU_ACTION:
3913 switch (WepMenu.state) {
3914 case WEP_STATE_SCRAP_PROMPT:
3915 case WEP_STATE_SCRAP_CONFIRM:
3916 case WEP_STATE_SCRAP_REFUSED:
3917 mes_no = 0xA4;
3918 break;
3919 }
3920
3921 break;
3922 case WEP_MENU_BUILDUP_SELECT:
3923 case WEP_MENU_BUILDUP_PREVIEW:
3924 EnableBuildUpModel(builds, weapon);
3925 int i;
3926 i = 0;
3927
3928 while (builds[i].weapon_no != -1) {
3929 COM_ITEM_INFO *info = GetCommonItemInfo(builds[i].weapon_no);
3930
3931 if (info != NULL) {
3932 builds[i].weapon_no = info->msg;
3933
3934 if (builds[i].enabled == 0) {
3935 builds[i].weapon_no = 2;
3936 }
3937 }
3938
3939 i++;
3940
3941 if (i > 4) {
3942 break;
3943 }
3944 }
3945
3946 if (WepMenu.mode == WEP_MENU_BUILDUP_SELECT) {
3947 s16 enabled;
3948
3949 if ((enabled = builds[WepMenu.board.cursor].enabled) != 0) {
3950 mes_no = 0xAE;
3951 name_mes = builds[WepMenu.board.cursor].weapon_no;
3952 }
3953
3954 if (enabled == 0) {
3955 mes_no = 0xAD;
3956 }
3957 }
3958
3959 break;
3960 case WEP_MENU_LIST: {
3961 int item_no = weapon->item_no;
3962
3963 if (item_no >= ITEM_WEAPON_START) {
3964 mes_no = GetWeaponMsgNo2(item_no) + 500;
3965 value = weapon->level;
3966 }
3967
3968 break;
3969 }
3970 case WEP_MENU_ATTACH_SOCKETS: {
3971 int item_no = weapon->attach[WepMenu.board.cursor].item_no;
3972
3973 if (item_no >= ITEM_ATTACH_START) {
3974 mes_no = item_no + 500;
3975 value = GetAttachVolumeForMsg(&weapon->attach[WepMenu.board.cursor]);
3976
3977 if (item_no == ITEM_ATTACH_SYNTHESIS_SPHERE) {
3978 name_mes = GetWeaponMsgNo2(weapon->attach[WepMenu.board.cursor].sphere_weapon_no);
3979 }
3980 } else {
3981 WEAPON_DATA *data = GetWeaponData(weapon->item_no);
3982
3983 if (data->hole[WepMenu.board.cursor] == 2) {
3984 mes_no = 0x70;
3985 } else {
3986 mes_no = 0x71;
3987 }
3988 }
3989
3990 break;
3991 }
3992 case WEP_MENU_ELEMENT:
3993 if (weapon->best_elem == WepMenu.element) {
3994 mes_no += 0x15;
3995 }
3996
3997 break;
3998 case WEP_MENU_ATTACH_TAGS:
3999 if (WepMenu.tag_page == WEP_TAG_ELEMENT && weapon->best_elem == WepMenu.tag_row) {
4000 mes_no += 0x15;
4001 }
4002
4003 break;
4004 case WEP_MENU_ATTACH_BOARD:
4005 switch (WepMenu.board.cursor_area) {
4006 case PERSONAL_BOARD_AREA_CELLS: {
4007 int held = BtlHaveItemPt->item_no;
4008
4009 if (held >= ITEM_ATTACH_START) {
4010 mes_no = held + 500;
4011 value = GetAttachVolumeForMsg(&WepMenu.board.held_attach);
4012
4013 if (BtlHaveItemPt->item_no == ITEM_ATTACH_SYNTHESIS_SPHERE) {
4014 name_mes = GetWeaponMsgNo2(WepMenu.board.held_attach.sphere_weapon_no);
4015 }
4016 } else {
4017 ATTACH_LIST *attach = &attachments[WepMenu.board.cursor];
4018 int item_no = attach->item_no;
4019
4020 if (item_no >= ITEM_ATTACH_START) {
4021 mes_no = item_no + 500;
4022 value = GetAttachVolumeForMsg(attach);
4023
4024 if (attachments[WepMenu.board.cursor].item_no == ITEM_ATTACH_SYNTHESIS_SPHERE) {
4025 name_mes = GetWeaponMsgNo2(attachments[WepMenu.board.cursor].sphere_weapon_no);
4026 }
4027 }
4028 }
4029
4030 break;
4031 }
4032 case PERSONAL_BOARD_AREA_TRASH:
4033 mes_no = 0xBE;
4034 break;
4035 }
4036
4037 break;
4038 }
4039
4040 if (WepMenu.state == WEP_STATE_WARNING) {
4041 s16 warnings[10] = {0xA1, 0xA2, 0xA3, 0x19B, 0x19C, 0x19D, 0xA8, 0xAA, 0xA9, 0xAB};
4042 help_no = warnings[WepMenu.warning_no];
4043 }
4044
4045 if (WepMenu.state == WEP_STATE_SCRAP_CONFIRM) {
4046 help_no = 0xA5;
4047 }
4048
4049 if (WepMenu.state == WEP_STATE_SCRAP_REFUSED) {
4050 help_no = 0xA6;
4051
4052 if (weapon->item_no == ITEM_WEAPON_SERPENT_SWORD && GetMenuHebikiriFlag() == 0) {
4053 help_no = 0xA7;
4054 }
4055 }
4056
4057 if (CommonMenuMes2.mes_made != mes_no || CommonMenuMes2.value != value || (CommonMenuMes2.mes_made == 0x24E && (CommonMenuMes2.mes_no[0] != name_mes + 100 || CommonMenuMes2.value != value))) {
4058 CommonMenuMes2.value_signed = true;
4059 CommonMenuMes2.value_show = false;
4060
4061 if (name_mes > 0) {
4062 CommonMenuMes2.mes_no[0] = name_mes + 100;
4063 }
4064
4065 CommonMenuMes2.value = value;
4066 CommonMenuMes2.mes_made = -1;
4067 CommonMenuMes2.MakeMesWin(mes_no);
4068 }
4069
4070 int changed = 0;
4071
4072 if (WepMenu.mode == WEP_MENU_BUILDUP_SELECT || WepMenu.mode == WEP_MENU_BUILDUP_PREVIEW) {
4073 s16 previous[3];
4074
4075 for (int i = 0; i < 3; i++) {
4076 previous[i] = CommonMenuMes1.mes_no[i];
4077
4078 if (previous[i] != builds[i].weapon_no + 100 && previous[i] > 100) {
4079 changed = 1;
4080 }
4081
4082 if (builds[i].enabled == 1) {
4083 CommonMenuMes1.mes_no[i] = builds[i].weapon_no + 100;
4084 } else if (builds[i].enabled == 0) {
4085 CommonMenuMes1.mes_no[i] = 2;
4086 }
4087
4088 if (builds[i].weapon_no <= 0) {
4089 CommonMenuMes1.mes_no[i] = -1;
4090 }
4091 }
4092 } else if (MenuWepLevelUp.operation_kind == WEP_EFFECT_NONE) {
4093 for (int i = 0; i < 4; i++) {
4094 CommonMenuMes1.mes_no[i] = -1;
4095
4096 if (i >= 0 && i < 10) {
4097 CommonMenuMes1.line_pos[i].x = -1;
4098 CommonMenuMes1.line_pos[i].y = -1;
4099 }
4100 }
4101 }
4102
4103 if ((CommonMenuMes1.mes_made != help_no && MenuWepLevelUp.operation_kind == WEP_EFFECT_NONE) || ((WepMenu.mode == WEP_MENU_BUILDUP_SELECT || WepMenu.mode == WEP_MENU_BUILDUP_PREVIEW) && changed != 0) || (CommonMenuMes1.mes_made != help_no && WepMenu.state == WEP_STATE_WARNING) || (CommonMenuMes1.mes_made != help_no && WepMenu.state == WEP_STATE_SCRAP_CONFIRM) || (CommonMenuMes1.mes_made != help_no && WepMenu.state == WEP_STATE_SCRAP_REFUSED)) {
4104 switch (WepMenu.state) {
4105 case WEP_STATE_WARNING:
4106 case WEP_STATE_SCRAP_CONFIRM:
4107 case WEP_STATE_SCRAP_REFUSED:
4108 CommonMenuMes1.stay_frame = true;
4109 break;
4110 }
4111
4112 CommonMenuMes1.mes_made = -1;
4113 CommonMenuMes1.MakeMesWin(help_no);
4114 }
4115}
4116
4120static int WeaponMenuKastumSelectUp(int row, int enabled_rows) {
4121 if (row == 0) {
4122 row = 7;
4123 }
4124
4125 int selected_row = 3;
4126
4127 while (row >= 4) {
4128 if (enabled_rows & (1 << (row - 4))) {
4129 selected_row = row - 1;
4130 break;
4131 }
4132
4133 row--;
4134 }
4135
4136 return selected_row;
4137}
4138
4142static int WeaponMenuKastumSelectDown(int row, int enabled_rows) {
4143 int selected_row = 0;
4144
4145 while (row <= 6) {
4146 if (enabled_rows & (1 << (row - 3))) {
4147 selected_row = row;
4148 break;
4149 }
4150
4151 row++;
4152 }
4153
4154 return selected_row;
4155}
4156
4164static int WeaponSelectKey() {
4165 int result = 0;
4166 int chara_num = 6;
4167 int prev_chara = WepMenu.chara;
4168
4169 switch (WepMenu.mode) {
4170 case WEP_MENU_LIST: {
4171 int done = 0;
4172
4173 if (GamePad.Down(PAD_LEFT) && 0 < WepMenu.weapon_slot) {
4174 WepMenu.weapon_slot--;
4175 }
4176
4177 if (GamePad.Down(PAD_RIGHT) && WepMenu.weapon_slot < 9) {
4178 WepMenu.weapon_slot++;
4179 }
4180
4181#ifdef PAL
4182 // Debug builds edit the selected weapon: level, every flag, maxed stats, and a cycle of element and
4183 // anti-monster values.
4184 if (DebugMode) {
4185 WEAPON_HAVE *weapon = GetNowSelectWeapon();
4186
4187 if (GamePad.Down2(PAD_CROSS) && weapon->level < 99) {
4188 weapon->level++;
4189 }
4190
4191 if (GamePad.Down2(PAD_R2 | PAD_R1)) {
4192 for (int i = 1; i <= 13; i++) {
4193 weapon->flags |= 1 << i;
4194 }
4195 }
4196
4197 if (GamePad.Down2(PAD_TRIANGLE)) {
4198 WEAPON_DATA *data = GetWeaponData(weapon->item_no);
4199 weapon->level = 99;
4200 weapon->attack = data->attack_max;
4201 weapon->endurance = 99;
4202 weapon->speed = 99;
4203 weapon->magic = data->magic_max;
4204 weapon->durability = 99;
4205 weapon->durability_f = 99.0f;
4206
4207 for (int i = 0; i < 5; i++) {
4208 weapon->elem[i] = 99;
4209 }
4210
4211 for (int i = 0; i < 10; i++) {
4212 weapon->vs_monster[i] = 99;
4213 }
4214
4215 weapon->synthesis_count = 49;
4216
4217 for (int i = 1; i <= 13; i++) {
4218 weapon->flags |= 1 << i;
4219 }
4220 }
4221
4222 if (GamePad.Down2(PAD_CIRCLE)) {
4223 weapon->flags = 0;
4224 weapon->flags = 0x36EA;
4225 }
4226
4227 static int now = 0;
4228 static int cnt = 0;
4229
4230 if (GamePad.Down2(PAD_SQUARE)) {
4231 now++;
4232
4233 if (now >= 4) {
4234 now = 0;
4235 }
4236
4237 if (now == 0) {
4238 for (int i = 0; i < 5; i++) {
4239 weapon->elem[i] = 0;
4240 }
4241
4242 for (int i = 0; i < 10; i++) {
4243 weapon->vs_monster[i] = 0;
4244 }
4245
4246 printf("now 0%\n");
4247 }
4248
4249 if (now == 1) {
4250 for (int i = 0; i < 5; i++) {
4251 weapon->elem[i] = 20;
4252 }
4253
4254 for (int i = 0; i < 10; i++) {
4255 weapon->vs_monster[i] = 20;
4256 }
4257
4258 printf("now 20%\n");
4259 }
4260
4261 if (now == 2) {
4262 for (int i = 0; i < 5; i++) {
4263 weapon->elem[i] = 50;
4264 }
4265
4266 for (int i = 0; i < 10; i++) {
4267 weapon->vs_monster[i] = 50;
4268 }
4269
4270 printf("now 50%\n");
4271 }
4272
4273 if (now == 3) {
4274 for (int i = 0; i < 5; i++) {
4275 weapon->elem[i] = 100;
4276 }
4277
4278 for (int i = 0; i < 10; i++) {
4279 weapon->vs_monster[i] = 100;
4280 }
4281
4282 printf("now 100%\n");
4283 }
4284
4285 for (int i = 0; i < now; i++) {
4286 ComMenuSePlay(MENU_SOUND_CONFIRM);
4287 }
4288 }
4289 }
4290
4291#endif
4292 if (GamePad.Down(PAD_CIRCLE)) {
4293 ComMenuSePlay(MENU_SOUND_REFUSE);
4294
4295 switch (WepMenu.open_mode) {
4296 case WEP_OPEN_VIEW_ONLY:
4297 break;
4298 case WEP_OPEN_FROM_BAR:
4299 if (BtlMenuMode == BATTLE_MENU_MODE_DUNGEON) {
4300 MenuTextureReload(MenuShadowReadBlock);
4301 DngActiveWeaponTextureCopy();
4302 }
4303
4304 BattleMenuFlag = BTLMENU_STATE_WEAPON_CLOSE;
4305 WepMenu.state = WEP_STATE_CLOSE;
4306 WepMenu.counter = 0;
4307 break;
4308 }
4309
4310 done = 1;
4311 } else if (GamePad.Down(PAD_CROSS)) {
4312 switch (WepMenu.open_mode) {
4313 case WEP_OPEN_FROM_BAR:
4314 if (GetDefaultWeaponNo(WepMenu.chara) > DngWepHavePt[WepMenu.weapon_slot].item_no) {
4315 ComMenuSePlay(MENU_SOUND_REFUSE);
4316 } else {
4317 WepMenu.mode = WEP_MENU_ACTION;
4318 WepMenu.board.cursor = WEP_ACTION_EQUIP;
4319 ComMenuSePlay(MENU_SOUND_CONFIRM);
4320 }
4321
4322 break;
4323 }
4324
4325 done = 1;
4326 }
4327
4328 if (!done) {
4329 if (GamePad.Down(PAD_R2 | PAD_R1)) {
4330 WepMenu.chara++;
4331
4332 if (WepMenu.chara >= chara_num) {
4333 WepMenu.chara = 0;
4334 }
4335 }
4336
4337 if (GamePad.Down(PAD_L2 | PAD_L1)) {
4338 WepMenu.chara--;
4339
4340 if (WepMenu.chara < 0) {
4341 WepMenu.chara = chara_num - 1;
4342 }
4343 }
4344 }
4345
4346 break;
4347 }
4348 case WEP_MENU_ACTION: {
4349 WEAPON_HAVE *weapon = GetNowSelectWeapon();
4350 int status = NowWeaponStatusValue(weapon);
4351
4352 if (GamePad.Down(PAD_UP)) {
4353 if (0 < WepMenu.board.cursor && WepMenu.board.cursor < 5) {
4354 WepMenu.board.cursor--;
4355 } else {
4356 WepMenu.board.cursor = WeaponMenuKastumSelectUp(WepMenu.board.cursor, status);
4357 }
4358 }
4359
4360 if (GamePad.Down(PAD_DOWN)) {
4361 if (WepMenu.board.cursor >= 3) {
4362 WepMenu.board.cursor = WeaponMenuKastumSelectDown(WepMenu.board.cursor + 1, status);
4363 } else {
4364 WepMenu.board.cursor++;
4365 }
4366 }
4367
4368 if (GamePad.Down(PAD_RIGHT) && WepMenu.board.cursor == WEP_ACTION_EQUIP) {
4369 WepMenu.state = WEP_STATE_SCRAP_PROMPT;
4370 WepMenu.confirm[0] = 1;
4371 ComMenuSePlay(MENU_SOUND_CURSOR);
4372 } else if (GamePad.Down(PAD_CROSS)) {
4373 s8 slot = WepMenu.weapon_slot;
4374 NowWeaponStatusValue(weapon);
4375
4376 switch (WepMenu.board.cursor) {
4377 case WEP_ACTION_EQUIP: {
4378 CDngStatusData *status_data = BtlMenuStatusPt;
4379 int zone;
4380
4381 if (status_data->GetActiveCharaStatus(WepMenu.chara) & AILMENT_CURSE) {
4382 ComMenuSePlay(MENU_SOUND_REFUSE);
4383 WepMenu.state = WEP_STATE_WARNING;
4384 WepMenu.warning_no = 3;
4385 } else if ((zone = BtlMenuStatusPt->res_limit_zone_current) == RES_LIMIT_ZONE_NO_WEAPON_CHANGE) {
4386 WepMenu.state = WEP_STATE_WARNING;
4387 WepMenu.warning_no = 4;
4388 ComMenuSePlay(MENU_SOUND_REFUSE);
4389 } else if (BtlMenuStatusPt->party_size <= WepMenu.chara) {
4390 WepMenu.state = WEP_STATE_WARNING;
4391 WepMenu.warning_no = 2;
4392 ComMenuSePlay(MENU_SOUND_REFUSE);
4393 } else {
4394 BtlMenuStatusPt->equipped_weapon_slot[WepMenu.chara] = slot;
4395 WepFrameRate = 0.0f;
4396 WepMenu.state = WEP_STATE_EQUIP;
4397 int chara = ((CUserStatus *) BtlMenuStatusPt)->cur_chara;
4398
4399 if (BtlMenuMode == BATTLE_MENU_MODE_DUNGEON && ((chara == CHARA_OSMOND && WepMenu.chara == CHARA_OSMOND) || (chara == CHARA_RUBY && WepMenu.chara == CHARA_RUBY))) {
4400 StartReadBG();
4401 DngWepEffectReadStart();
4402 }
4403
4404 ComMenuSePlay(SE_WEAPON_EQUIP);
4405 }
4406
4407 break;
4408 }
4409 case WEP_ACTION_ATTACH: {
4410 WepMenu.mode = WEP_MENU_ATTACH_BOARD;
4411 WepMenu.board.cursor = 0;
4412 WepMenu.tag_page = WEP_TAG_STATUS;
4413 SetOldEffectKind(weapon->best_elem);
4414 int holes = GetWeaponHoleNum(weapon->item_no);
4415 CMenuCursor *cursor = SaveData->GetMenuCursor();
4416 int max = PersonalRetMax(BOARD_PAGE_ATTACH);
4417
4418 if (cursor->reset_pos == 0) {
4419 WepMenu.mode = cursor->mode[2];
4420
4421 if (WepMenu.mode < WEP_MENU_ATTACH_WEAPON || WepMenu.mode > WEP_MENU_ATTACH_TAGS) {
4422 WepMenu.mode = WEP_MENU_ATTACH_BOARD;
4423 }
4424
4425 WepMenu.board.cursor = cursor->pos[2];
4426
4427 switch (WepMenu.mode) {
4428 case WEP_MENU_ATTACH_SOCKETS:
4429 if (holes - 1 < WepMenu.board.cursor) {
4430 WepMenu.board.cursor = holes - 1;
4431 }
4432
4433 break;
4434 case WEP_MENU_ATTACH_BOARD:
4435 WepMenu.board.top_row = WepMenu.board.cursor / 5;
4436
4437 if (max / 5 - 4 < WepMenu.board.top_row) {
4438 WepMenu.board.top_row = max / 5 - 4;
4439
4440 while (max < WepMenu.board.cursor) {
4441 WepMenu.board.cursor -= 5;
4442 }
4443
4444 while (WepMenu.board.cursor < 0) {
4445 WepMenu.board.cursor += 5;
4446 }
4447 }
4448
4449 break;
4450 case WEP_MENU_ATTACH_WEAPON:
4451 WepMenu.board.cursor = 0;
4452 break;
4453 case WEP_MENU_ATTACH_TAGS:
4454 break;
4455 }
4456 } else {
4457 WepMenu.board.top_row = WepMenu.board.cursor / 5;
4458
4459 if (max / 5 - 4 < WepMenu.board.top_row) {
4460 WepMenu.board.top_row = max / 5 - 4;
4461
4462 while (max < WepMenu.board.cursor) {
4463 WepMenu.board.cursor -= 5;
4464 }
4465
4466 while (WepMenu.board.cursor < 0) {
4467 WepMenu.board.cursor += 5;
4468 }
4469 }
4470 }
4471
4472 if (holes <= 0) {
4473 WepMenu.sockets_enabled = false;
4474 } else {
4475 WepMenu.sockets_enabled = true;
4476 }
4477
4478 if (WepMenu.board.cursor < 0) {
4479 WepMenu.board.cursor = 0;
4480 }
4481
4482 int pages = max / 5;
4483 WepMenu.board.y = 127 - WepMenu.board.top_row * 40;
4484 WepMenu.board.scroll = 140.0f + 114.0f * WepMenu.board.top_row / pages;
4485 ComMenuSePlay(MENU_SOUND_CONFIRM);
4486 break;
4487 }
4488 case WEP_ACTION_ELEMENT:
4489 WepMenu.mode = WEP_MENU_ELEMENT;
4490 WepMenu.tag_page = WEP_TAG_ELEMENT;
4491 WepMenu.element = weapon->best_elem;
4492
4493 if (WepMenu.element < 0 || WepMenu.element > 4) {
4494 WepMenu.element = 0;
4495 }
4496
4497 ComMenuSePlay(MENU_SOUND_CONFIRM);
4498 break;
4499 case WEP_ACTION_REPAIR:
4500 if (GetNowItemNum(ITEM_REPAIR_POWDER, MenuItemPackPt) <= 0) {
4501 ComMenuSePlay(MENU_SOUND_REFUSE);
4502 } else {
4503 int chara = WepMenu.chara;
4504 CUserStatus *status_data = (CUserStatus *) BtlMenuStatusPt;
4505
4506 if (ItemUseFunc(status_data, ITEM_REPAIR_POWDER, chara, ITEM_USE_ON_BOARD_WEAPON, weapon) == 2) {
4507 DeleteItemAfterUseItem(ITEM_REPAIR_POWDER, MenuItemPackPt);
4508 ComMenuSePlay(SE_WEAPON_REPAIR);
4509
4510 if (IsDefaultWeapon(weapon->item_no) >= 0) {
4511 SetMenuWeaponModelReference(slot, 1, 1);
4512 }
4513
4514 MenuWepLevelUp.WepRecover(weapon, &DngWeaponFrm[slot], WepMenuEffectReadBuf, BtlMenuExReadBlock);
4515 WepMenu.state = WEP_STATE_REPAIR_EFFECT;
4516 } else {
4517 ComMenuSePlay(MENU_SOUND_REFUSE);
4518 }
4519 }
4520
4521 break;
4522 case WEP_ACTION_LEVELUP: {
4523 int item_no = weapon->item_no;
4524
4525 if (item_no == GetDefaultWeaponNo(WepMenu.chara)) {
4526 WepMenu.state = WEP_STATE_WARNING;
4527 WepMenu.warning_no = 7;
4528 ComMenuSePlay(MENU_SOUND_REFUSE);
4529 } else if (item_no == ITEM_WEAPON_SERPENT_SWORD && GetMenuHebikiriFlag() == 0) {
4530 WepMenu.state = WEP_STATE_WARNING;
4531 WepMenu.warning_no = 5;
4532 ComMenuSePlay(MENU_SOUND_REFUSE);
4533 } else if (weapon->level >= 99) {
4534 WepMenu.state = WEP_STATE_WARNING;
4535 WepMenu.warning_no = 8;
4536 ComMenuSePlay(MENU_SOUND_REFUSE);
4537 } else {
4538 WepMenu.mode = WEP_MENU_LEVELUP_CONFIRM;
4539 WepMenu.board.cursor = 1;
4540 ComMenuSePlay(MENU_SOUND_CONFIRM);
4541 }
4542
4543 break;
4544 }
4545 case WEP_ACTION_STATUS_BREAK: {
4546 int count;
4547 int i;
4548 DNG_CONSUMABLE *items = BtlMenuStatusPt->consumable_items;
4549 count = 0;
4550
4551 for (i = 0; i < 40; i++) {
4552 if (items[i].id >= ITEM_ATTACH_START) {
4553 count++;
4554 }
4555 }
4556
4557 if (count >= 40) {
4558 WepMenu.state = WEP_STATE_WARNING;
4559 WepMenu.warning_no = 1;
4560 ComMenuSePlay(MENU_SOUND_REFUSE);
4561 } else {
4562 WepMenu.mode = WEP_MENU_STATUS_BREAK_CONFIRM;
4563 WepMenu.board.cursor = 1;
4564 ComMenuSePlay(MENU_SOUND_CONFIRM);
4565 }
4566
4567 break;
4568 }
4569 case WEP_ACTION_BUILDUP:
4570 WepMenu.mode = WEP_MENU_BUILDUP_SELECT;
4571 WepMenu.board.cursor = 0;
4572 ComMenuSePlay(MENU_SOUND_CONFIRM);
4573 break;
4574 }
4575 } else if (GamePad.Down(PAD_CIRCLE)) {
4576 WepMenu.mode = WEP_MENU_LIST;
4577 ComMenuSePlay(MENU_SOUND_REFUSE);
4578 }
4579
4580 break;
4581 }
4582 case WEP_MENU_ELEMENT:
4583 WepMenu.tag_page = WEP_TAG_ELEMENT;
4584
4585 if (GamePad.Down(PAD_L2 | PAD_R2 | PAD_L1 | PAD_R1)) {
4586 ComMenuSePlay(MENU_SOUND_REFUSE);
4587 }
4588
4589 if (GamePad.Down(PAD_UP) && 0 < WepMenu.element) {
4590 WepMenu.element--;
4591 }
4592
4593 if (GamePad.Down(PAD_DOWN) && WepMenu.element < 4) {
4594 WepMenu.element++;
4595 }
4596
4597 if (GamePad.Down(PAD_CROSS)) {
4598 WEAPON_HAVE *weapon = GetNowSelectWeapon();
4599 WEAPON_HAVE total;
4600 WeaponAllValueSet(weapon, &total, 0);
4601
4602 if (WeaponMenuCheckEnableSetElem(weapon, &total, WepMenu.element)) {
4603 ComMenuSePlay(MENU_SOUND_REFUSE);
4604 } else {
4605 ComMenuSePlay(MENU_SOUND_CONFIRM);
4606 }
4607 } else if (GamePad.Down(PAD_CIRCLE)) {
4608 WepMenu.mode = WEP_MENU_ACTION;
4609
4610 if (BtlMenuMode == BATTLE_MENU_MODE_DUNGEON && ((CUserStatus *) BtlMenuStatusPt)->cur_chara == CHARA_RUBY && WepMenu.chara == CHARA_RUBY) {
4611 StartReadBG();
4612 DngWepEffectReadStart();
4613 }
4614
4615 ComMenuSePlay(MENU_SOUND_REFUSE);
4616 }
4617
4618 break;
4619 case WEP_MENU_LEVELUP_CONFIRM:
4620 if (GamePad.Down(PAD_UP | PAD_DOWN)) {
4621 if (WepMenu.board.cursor != 0) {
4622 WepMenu.board.cursor = 0;
4623 } else {
4624 WepMenu.board.cursor = 1;
4625 }
4626 }
4627
4628 if (WepMenu.board.cursor == 0 && GamePad.Down(PAD_CROSS)) {
4629 s8 slot = WepMenu.weapon_slot;
4630
4631 if (DngWepHavePt[slot].experience < GetWeaponMaxExp(&DngWepHavePt[slot])) {
4632 DeleteItemAfterUseItem(ITEM_POWERUP_POWDER, MenuItemPackPt);
4633 }
4634
4635 MenuWepLevelUp.SetLevelUpValue(&DngWepHavePt[slot], &DngWeaponFrm[slot], WepMenuEffectReadBuf, BtlMenuExReadBlock);
4636 WepMenu.state = WEP_STATE_LEVELUP_EFFECT;
4637 WepMenu.mode = WEP_MENU_LIST;
4638 WepMenu.board.cursor = 0;
4639 ComMenuSePlay(MENU_SOUND_CONFIRM);
4640 } else if ((WepMenu.board.cursor == 1 && GamePad.Down(PAD_CROSS)) || GamePad.Down(PAD_CIRCLE)) {
4641 WepMenu.mode = WEP_MENU_ACTION;
4642 WepMenu.board.cursor = WEP_ACTION_LEVELUP;
4643 ComMenuSePlay(MENU_SOUND_REFUSE);
4644 }
4645
4646 break;
4647 case WEP_MENU_STATUS_BREAK_CONFIRM:
4648 if (GamePad.Down(PAD_UP | PAD_DOWN)) {
4649 if (WepMenu.board.cursor != 0) {
4650 WepMenu.board.cursor = 0;
4651 } else {
4652 WepMenu.board.cursor = 1;
4653 }
4654 }
4655
4656 if ((WepMenu.board.cursor == 1 && GamePad.Down(PAD_CROSS)) || GamePad.Down(PAD_CIRCLE)) {
4657 WepMenu.mode = WEP_MENU_ACTION;
4658 WepMenu.board.cursor = WEP_ACTION_STATUS_BREAK;
4659 ComMenuSePlay(MENU_SOUND_REFUSE);
4660 } else if (WepMenu.board.cursor == 0 && GamePad.Down(PAD_CROSS)) {
4661 int slot = WepMenu.weapon_slot;
4662 CWeaponLevelUp *buffer = (CWeaponLevelUp *) (MenuExCashBuffer.base + MenuExCashBuffer.used * 16);
4663 MenuWepLevelUp.SetStatusBreak(&DngWepHavePt[slot], &DngWeaponFrm[slot], buffer, BtlMenuExReadBlock);
4664 WepMenu.state = WEP_STATE_STATUS_BREAK_EFFECT;
4665 WepMenu.mode = WEP_MENU_LIST;
4666 WepMenu.board.cursor = 0;
4667 ComMenuSePlay(MENU_SOUND_CONFIRM);
4668 }
4669
4670 break;
4671 case WEP_MENU_BUILDUP_SELECT: {
4672 WEAPON_HAVE *weapon = GetNowSelectWeapon();
4673 WEP_BUILDUP_INFO info[7];
4674 int build_up;
4675 EnableBuildUpModel(info, weapon);
4676 int count = WeaponStatusBuildUp(weapon, build_up);
4677
4678 if (GamePad.Down(PAD_UP)) {
4679 WepMenu.board.cursor--;
4680 }
4681
4682 if (GamePad.Down(PAD_DOWN)) {
4683 WepMenu.board.cursor++;
4684 }
4685
4686 if (WepMenu.board.cursor < 0) {
4687 WepMenu.board.cursor = count - 1;
4688 }
4689
4690 if (count - 1 < WepMenu.board.cursor) {
4691 WepMenu.board.cursor = 0;
4692 }
4693
4694 if (GamePad.Down(PAD_CIRCLE)) {
4695 WepMenu.board.cursor = WEP_ACTION_BUILDUP;
4696 WepMenu.mode = WEP_MENU_ACTION;
4697 } else if (GamePad.Down(PAD_CROSS)) {
4698 int attached = 0;
4699
4700 for (int i = 0; i < GetWeaponHoleNum(weapon->item_no); i++) {
4701 if (weapon->attach[i].item_no >= ITEM_ATTACH_START) {
4702 attached++;
4703 }
4704 }
4705
4706 int weapon_no = info[WepMenu.board.cursor].weapon_no;
4707 int enabled = info[WepMenu.board.cursor].enabled;
4708
4709 if (enabled == 1 && attached == 0) {
4710 MenuWepLevelUp.buildup_weapon_no = weapon_no;
4711 WepMenu.mode = WEP_MENU_BUILDUP_CONFIRM;
4712 WepMenu.board.cursor = 1;
4713 } else if (enabled == 0) {
4714 WepMenu.mode = WEP_MENU_BUILDUP_PREVIEW;
4715 WepMenu.tag_page = WEP_TAG_STATUS;
4716 } else {
4717 WepMenu.state = WEP_STATE_WARNING;
4718 WepMenu.warning_no = 6;
4719 }
4720 }
4721
4722 break;
4723 }
4724 case WEP_MENU_BUILDUP_CONFIRM:
4725 if (GamePad.Down(PAD_UP | PAD_DOWN)) {
4726 if (WepMenu.board.cursor != 0) {
4727 WepMenu.board.cursor = 0;
4728 } else {
4729 WepMenu.board.cursor = 1;
4730 }
4731 }
4732
4733 if ((WepMenu.board.cursor == 1 && GamePad.Down(PAD_CROSS)) || GamePad.Down(PAD_CIRCLE)) {
4734 WepMenu.mode = WEP_MENU_ACTION;
4735 WepMenu.board.cursor = WEP_ACTION_BUILDUP;
4736 ComMenuSePlay(MENU_SOUND_REFUSE);
4737 } else if (WepMenu.board.cursor == 0 && GamePad.Down(PAD_CROSS)) {
4738 MenuWepLevelUp.SetBuildUp(&DngWepHavePt[WepMenu.weapon_slot], &DngWeaponFrm[WepMenu.weapon_slot], WepMenuEffectReadBuf, BtlMenuExReadBlock);
4739 WepMenu.state = WEP_STATE_BUILDUP_EFFECT;
4740 WepMenu.mode = WEP_MENU_LIST;
4741 WepMenu.board.cursor = 0;
4742 ComMenuSePlay(MENU_SOUND_CONFIRM);
4743 }
4744
4745 break;
4746 case WEP_MENU_BUILDUP_PREVIEW:
4747 if (GamePad.Down(PAD_L2 | PAD_L1)) {
4748 WepMenu.tag_page--;
4749
4750 if (WepMenu.tag_page < 0) {
4751 WepMenu.tag_page = WEP_TAG_VS_MONSTER;
4752 }
4753
4754 ComMenuSePlay(MENU_SOUND_CURSOR);
4755 }
4756
4757 if (GamePad.Down(PAD_R2 | PAD_R1)) {
4758 WepMenu.tag_page++;
4759
4760 if (WepMenu.tag_page > WEP_TAG_VS_MONSTER) {
4761 WepMenu.tag_page = WEP_TAG_STATUS;
4762 }
4763
4764 ComMenuSePlay(MENU_SOUND_CURSOR);
4765 }
4766
4767 if (GamePad.Down(PAD_CIRCLE)) {
4768 WepMenu.mode = WEP_MENU_BUILDUP_SELECT;
4769 ComMenuSePlay(MENU_SOUND_REFUSE);
4770 }
4771
4772 break;
4773 }
4774
4775 if (prev_chara != WepMenu.chara) {
4776 int chara = ((CUserStatus *) BtlMenuStatusPt)->cur_chara;
4777
4778 if (BtlMenuMode == BATTLE_MENU_MODE_DUNGEON && chara == prev_chara) {
4779 DngWeaponEquipModelBuild(chara, MenuExtendReadBlock, BtlMenuReadBuf);
4780 }
4781
4782 int selected_chara = WepMenu.chara;
4783 CDngStatusData *status_data = BtlMenuStatusPt;
4784 DngWepHavePt = status_data->chara_weapons[selected_chara];
4785
4786 if (StartReadWepMDS(BtlMenuReadBuf, WepMenu.chara)) {
4787 MenuExTextureReadFlag = MENU_EX_TEX_UNREAD;
4788 WepMenu.state = WEP_STATE_CHARA_CHANGE;
4789 WepMenu.counter = 0;
4790
4791 if (abs(prev_chara - WepMenu.chara) > 1) {
4792 for (int i = 0; i < 6; i++) {
4793 SysChara[i].x = (SysChara[i].chara - WepMenu.chara) * 110 + 270;
4794 }
4795 }
4796
4797 int next_chara = WepMenu.chara;
4798 CDngStatusData *next_status_data = BtlMenuStatusPt;
4799 DngWepHavePt = next_status_data->chara_weapons[next_chara];
4800 WepMenu.weapon_slot = BtlMenuStatusPt->equipped_weapon_slot[WepMenu.chara];
4801
4802 if (WepMenu.weapon_slot < 0 || WepMenu.weapon_slot >= 10) {
4803 WepMenu.weapon_slot = 0;
4804 }
4805
4806 WeaponPos = 0xE8 - WepMenu.weapon_slot * 0xD6;
4807 WepPolyPos = 2.0f + 16.0f * -WepMenu.weapon_slot;
4808 WepMenu.state = WEP_STATE_IDLE;
4809 WepMenu.counter = 0;
4810 result = 0;
4811 } else {
4812 ComMenuSePlay(MENU_SOUND_REFUSE);
4813 }
4814 }
4815
4816 return result;
4817}
4818
4822static inline void SetCursorPos(CMenuCursor *cursor, int menu, int pos) {
4823 cursor->pos[menu] = pos;
4824}
4825
4829static inline void SetCursorChara(CMenuCursor *cursor, int chara) {
4830 cursor->chara_no = chara;
4831}
4832
4840static void WepAttachHaveCancel() {
4841 ATTACH_LIST *slot;
4842 s16 held = BtlHaveItemPt->item_no;
4843
4844 if (held >= ITEM_ATTACH_START) {
4845 switch (BtlHaveItemPt->from_page) {
4846 case WEP_MENU_ATTACH_BOARD: {
4847 ATTACH_LIST *items = (ATTACH_LIST *) BtlMenuStatusPt->consumable_items;
4848 slot = &items[BtlHaveItemPt->from_slot];
4849 break;
4850 }
4851 case WEP_MENU_ATTACH_SOCKETS:
4852 slot = &DngWepHavePt[WepMenu.weapon_slot].attach[BtlHaveItemPt->from_slot];
4853 break;
4854 }
4855
4856 if (slot != NULL) {
4857 s16 item_no = slot->item_no;
4858 MenuDataSwap(slot, &WepMenu.board.held_attach);
4859 BtlHaveItemPt->item_no = item_no;
4860 slot->item_no = held;
4861 }
4862
4863 if (BtlHaveItemPt->item_no < ITEM_ATTACH_START) {
4864 InitHaveData(BtlHaveItemPt);
4865 }
4866 } else {
4867 CMenuCursor *cursor = SaveData->GetMenuCursor();
4868
4869 if (cursor->reset_pos == 0) {
4870 cursor->mode[2] = WepMenu.mode;
4871 SetCursorPos(cursor, 2, WepMenu.board.cursor);
4872 }
4873
4874 WepMenu.mode = WEP_MENU_ACTION;
4875 WepMenu.board.cursor = WEP_ACTION_ATTACH;
4876 WepMenu.sockets_enabled = false;
4877 GetNowSelectWeapon();
4878
4879 if (BtlMenuMode == BATTLE_MENU_MODE_DUNGEON && BtlMenuStatusPt->cur_chara == CHARA_RUBY && WepMenu.chara == CHARA_RUBY) {
4880 StartReadBG();
4881 DngWepEffectReadStart();
4882 }
4883 }
4884}
4885
4886void WeaponMenuAttachModeKey() {
4887 switch (WepMenu.mode) {
4888 case WEP_MENU_ATTACH_TAGS:
4889 case WEP_MENU_ATTACH_SOCKETS:
4890 case WEP_MENU_ATTACH_BOARD:
4891 case WEP_MENU_ATTACH_WEAPON: {
4892 int page = WepMenu.tag_page;
4893
4894 if (GamePad.Down(PAD_R2 | PAD_R1) != 0) {
4895 WepMenu.tag_page++;
4896
4897 if (WepMenu.tag_page > WEP_TAG_VS_MONSTER) {
4898 WepMenu.tag_page = WEP_TAG_STATUS;
4899 }
4900 }
4901
4902 if (GamePad.Down(PAD_L2 | PAD_L1) != 0) {
4903 WepMenu.tag_page--;
4904
4905 if (WepMenu.tag_page < 0) {
4906 WepMenu.tag_page = WEP_TAG_VS_MONSTER;
4907 }
4908 }
4909
4910 if (page != WepMenu.tag_page) {
4911 int rows[3] = {5, 4, 9};
4912
4913 if (rows[WepMenu.tag_page] < WepMenu.tag_row) {
4914 WepMenu.tag_row = rows[WepMenu.tag_page];
4915 }
4916
4917 ComMenuSePlay(MENU_SOUND_CURSOR);
4918 }
4919
4920 break;
4921 }
4922 }
4923
4924 int row = WepMenu.tag_row;
4925 s16 mode = WepMenu.mode;
4926 WeaponMenuSelectKeyLockFlag = 0;
4927
4928 switch (mode) {
4929 case WEP_MENU_ATTACH_WEAPON:
4930 WeaponMenuActWepKey();
4931 break;
4932 case WEP_MENU_ATTACH_TAGS:
4933 WeaponMenuTagKey();
4934 break;
4935 case WEP_MENU_ATTACH_SOCKETS:
4936 WeaponMenuAttachWepKey();
4937 break;
4938 case WEP_MENU_ATTACH_BOARD:
4939 WeaponMenuAttachKey();
4940 break;
4941 }
4942
4943 if ((row != WepMenu.tag_row || mode != WepMenu.mode) && GamePad.Down(PAD_CIRCLE) == 0) {
4944 ComMenuSePlay(MENU_SOUND_CURSOR);
4945 }
4946}
4947
4955static void WeaponMenuActWepKey() {
4956 if (GamePad.Down(PAD_RIGHT) != 0) {
4957 WepMenu.mode = WEP_MENU_ATTACH_BOARD;
4958 WepMenu.board.cursor = WepMenu.board.top_row * 5 + 10;
4959 } else if (GamePad.Down(PAD_DOWN) != 0) {
4960 WepMenu.mode = WEP_MENU_ATTACH_TAGS;
4961 WepMenu.tag_row = WEP_TAG_ROW_DURABILITY;
4962 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
4963 ComMenuSePlay(MENU_SOUND_REFUSE);
4964 WepAttachHaveCancel();
4965 }
4966}
4967
4968void WeaponMenuTagKey() {
4969 int moved = 0;
4970 s16 rows[3] = {5, 4, 10};
4971
4972 if (WepMenu.tag_row < 0) {
4973 WepMenu.tag_row = 0;
4974 }
4975
4976 if (rows[WepMenu.tag_page] < WepMenu.tag_row) {
4977 WepMenu.tag_row = rows[WepMenu.tag_page];
4978 }
4979
4980 GetWeaponHoleNum(GetNowSelectWeapon()->item_no);
4981
4982 switch (WepMenu.tag_page) {
4983 case WEP_TAG_STATUS:
4984 if (GamePad.Down(PAD_UP) != 0) {
4985 moved = 1;
4986
4987 if (0 < WepMenu.tag_row) {
4988 WepMenu.tag_row--;
4989 } else if (WepMenu.sockets_enabled != 0) {
4990 WepMenu.mode = WEP_MENU_ATTACH_SOCKETS;
4991 } else {
4992 WepMenu.mode = WEP_MENU_ATTACH_WEAPON;
4993 }
4994 } else if (GamePad.Down(PAD_DOWN) != 0) {
4995 moved = 1;
4996
4997 if (WepMenu.tag_row < rows[WepMenu.tag_page]) {
4998 WepMenu.tag_row++;
4999 }
5000 } else if (GamePad.Down(PAD_CROSS) != 0) {
5001 moved = 1;
5002 ComMenuSePlay(MENU_SOUND_REFUSE);
5003 }
5004
5005#ifdef PAL
5006 // Debug builds step the status row under the cursor up or down, and max it out.
5007 if (DebugMode) {
5008 WEAPON_HAVE total;
5009 WEAPON_HAVE *weapon = GetNowSelectWeapon();
5010 WEAPON_DATA *data = GetWeaponData(weapon->item_no);
5011 WeaponAllValueSet(weapon, &total, 0);
5012
5013 if (GamePad.On2(PAD_RIGHT)) {
5014 switch (WepMenu.tag_row) {
5015 case WEP_TAG_ROW_DURABILITY:
5016 if (weapon->durability_f < weapon->durability) {
5017 weapon->durability_f += 1.0f;
5018 }
5019
5020 break;
5021 case WEP_TAG_ROW_EXP:
5022 if (weapon->experience < GetWeaponMaxExp(weapon)) {
5023 weapon->experience++;
5024 }
5025
5026 break;
5027 case WEP_TAG_ROW_ATTACK:
5028 if (total.attack < data->attack_max) {
5029 weapon->attack++;
5030 }
5031
5032 break;
5033 case WEP_TAG_ROW_ENDURANCE:
5034 if (weapon->endurance < 99) {
5035 weapon->endurance++;
5036 }
5037
5038 break;
5039 case WEP_TAG_ROW_SPEED:
5040 if (weapon->speed < 99) {
5041 weapon->speed++;
5042 }
5043
5044 break;
5045 case WEP_TAG_ROW_MAGIC:
5046 if (total.magic < data->magic_max) {
5047 weapon->magic++;
5048 }
5049
5050 break;
5051 }
5052 }
5053
5054 if (GamePad.On2(PAD_LEFT)) {
5055 switch (WepMenu.tag_row) {
5056 case WEP_TAG_ROW_DURABILITY:
5057 if (1.0f < weapon->durability_f) {
5058 weapon->durability_f -= 1.0f;
5059 }
5060
5061 break;
5062 case WEP_TAG_ROW_EXP:
5063 if (0 < weapon->experience) {
5064 weapon->experience--;
5065 }
5066
5067 break;
5068 case WEP_TAG_ROW_ATTACK:
5069 if (0 < weapon->attack) {
5070 weapon->attack--;
5071 }
5072
5073 break;
5074 case WEP_TAG_ROW_ENDURANCE:
5075 if (0 < weapon->endurance) {
5076 weapon->endurance--;
5077 }
5078
5079 break;
5080 case WEP_TAG_ROW_SPEED:
5081 if (0 < weapon->speed) {
5082 weapon->speed--;
5083 }
5084
5085 break;
5086 case WEP_TAG_ROW_MAGIC:
5087 if (0 < weapon->magic) {
5088 weapon->magic--;
5089 }
5090
5091 break;
5092 }
5093 }
5094
5095 if (GamePad.On2(PAD_CROSS)) {
5096 switch (WepMenu.tag_row) {
5097 case WEP_TAG_ROW_DURABILITY:
5098 if (weapon->durability < 99) {
5099 weapon->durability++;
5100 }
5101
5102 break;
5103 }
5104 }
5105
5106 if (GamePad.On2(PAD_CIRCLE)) {
5107 switch (WepMenu.tag_row) {
5108 case WEP_TAG_ROW_DURABILITY:
5109 if (weapon->durability_f < weapon->durability) {
5110 weapon->durability--;
5111 }
5112
5113 break;
5114 }
5115 }
5116
5117 if (GamePad.Down2(PAD_TRIANGLE)) {
5118 switch (WepMenu.tag_row) {
5119 case WEP_TAG_ROW_ATTACK:
5120 weapon->attack = 99;
5121 break;
5122 case WEP_TAG_ROW_ENDURANCE:
5123 weapon->endurance = 99;
5124 break;
5125 case WEP_TAG_ROW_SPEED:
5126 weapon->speed = 99;
5127 break;
5128 case WEP_TAG_ROW_MAGIC:
5129 weapon->magic = 99;
5130 break;
5131 }
5132 }
5133 }
5134
5135#endif
5136 break;
5137 case WEP_TAG_ELEMENT:
5138 if (GamePad.Down(PAD_UP) != 0) {
5139 moved = 1;
5140
5141 if (0 < WepMenu.tag_row) {
5142 WepMenu.tag_row--;
5143 } else if (WepMenu.sockets_enabled != 0) {
5144 WepMenu.mode = WEP_MENU_ATTACH_SOCKETS;
5145 } else {
5146 WepMenu.mode = WEP_MENU_ATTACH_WEAPON;
5147 }
5148 } else if (GamePad.Down(PAD_DOWN) != 0) {
5149 moved = 1;
5150
5151 if (WepMenu.tag_row < rows[WepMenu.tag_page]) {
5152 WepMenu.tag_row++;
5153 }
5154 } else if (GamePad.Down(PAD_CROSS) != 0) {
5155 WEAPON_HAVE total;
5156 moved = 1;
5157 WEAPON_HAVE *weapon = GetNowSelectWeapon();
5158 WeaponAllValueSet(weapon, &total, 0);
5159
5160 if (WeaponMenuCheckEnableSetElem(weapon, &total, WepMenu.tag_row) != 0) {
5161 ComMenuSePlay(MENU_SOUND_REFUSE);
5162 } else {
5163 ComMenuSePlay(MENU_SOUND_CONFIRM);
5164 }
5165 }
5166
5167#ifdef PAL
5168 if (DebugMode) {
5169 if (GamePad.On2(PAD_RIGHT)) {
5170 WEAPON_HAVE *weapon = GetNowSelectWeapon();
5171
5172 if (weapon->elem[WepMenu.tag_row] < 99) {
5173 weapon->elem[WepMenu.tag_row]++;
5174 }
5175 }
5176
5177 if (GamePad.On2(PAD_LEFT)) {
5178 WEAPON_HAVE *weapon = GetNowSelectWeapon();
5179
5180 if (0 < weapon->elem[WepMenu.tag_row]) {
5181 weapon->elem[WepMenu.tag_row]--;
5182 }
5183 }
5184 }
5185
5186#endif
5187 break;
5188 case WEP_TAG_VS_MONSTER:
5189 if (GamePad.Down(PAD_UP) != 0) {
5190 moved = 1;
5191
5192 if (WepMenu.tag_row % 5 != 0) {
5193 WepMenu.tag_row--;
5194 } else if (WepMenu.sockets_enabled != 0) {
5195 WepMenu.mode = WEP_MENU_ATTACH_SOCKETS;
5196 } else {
5197 WepMenu.mode = WEP_MENU_ATTACH_WEAPON;
5198 }
5199 } else if (GamePad.Down(PAD_DOWN) != 0) {
5200 moved = 1;
5201
5202 if (WepMenu.tag_row % 5 != 4) {
5203 WepMenu.tag_row++;
5204 }
5205 } else if (GamePad.Down(PAD_LEFT) != 0) {
5206 moved = 1;
5207
5208 if (WepMenu.tag_row >= 5) {
5209 WepMenu.tag_row -= 5;
5210 }
5211 } else if (GamePad.Down(PAD_CROSS) != 0) {
5212 moved = 1;
5213 ComMenuSePlay(MENU_SOUND_REFUSE);
5214 }
5215
5216#ifdef PAL
5217 if (DebugMode) {
5218 if (GamePad.On2(PAD_RIGHT)) {
5219 WEAPON_HAVE *weapon = GetNowSelectWeapon();
5220
5221 if (weapon->vs_monster[WepMenu.tag_row] < 99) {
5222 weapon->vs_monster[WepMenu.tag_row]++;
5223 }
5224 }
5225
5226 if (GamePad.On2(PAD_LEFT)) {
5227 WEAPON_HAVE *weapon = GetNowSelectWeapon();
5228
5229 if (0 < weapon->vs_monster[WepMenu.tag_row]) {
5230 weapon->vs_monster[WepMenu.tag_row]--;
5231 }
5232 }
5233 }
5234
5235#endif
5236 break;
5237 }
5238
5239 if (moved != 0) {
5240 return;
5241 }
5242
5243 if (GamePad.Down(PAD_CIRCLE) != 0) {
5244 ComMenuSePlay(MENU_SOUND_REFUSE);
5245 WepAttachHaveCancel();
5246 return;
5247 }
5248
5249 if (GamePad.Down(PAD_RIGHT) != 0) {
5250 switch (WepMenu.tag_page) {
5251 case WEP_TAG_VS_MONSTER:
5252 if (WepMenu.tag_row < 5) {
5253 WepMenu.tag_row += 5;
5254 return;
5255 }
5256
5257 WepMenu.mode = WEP_MENU_ATTACH_BOARD;
5258 WepMenu.board.cursor = (WepMenu.board.top_row + 2) * 5;
5259 return;
5260 case WEP_TAG_STATUS:
5261 case WEP_TAG_ELEMENT:
5262 WepMenu.mode = WEP_MENU_ATTACH_BOARD;
5263 WepMenu.board.cursor = (WepMenu.board.top_row + 2) * 5;
5264 break;
5265 }
5266 }
5267}
5268
5276static void WeaponMenuAttachWepKey() {
5277 int moved = 0;
5278 WEAPON_HAVE *weapon = GetNowSelectWeapon();
5279
5280 if (GamePad.Down(PAD_LEFT)) {
5281 moved = 1;
5282
5283 if (0 < WepMenu.board.cursor) {
5284 WepMenu.board.cursor--;
5285 }
5286 }
5287
5288 int holes = GetWeaponHoleNum(weapon->item_no);
5289
5290 if (WepMenu.board.cursor > holes - 1) {
5291 WepMenu.board.cursor = holes - 1;
5292
5293 if (WepMenu.board.cursor < 0) {
5294 WepMenu.board.cursor = 0;
5295 WepMenu.mode = WEP_MENU_ATTACH_WEAPON;
5296 return;
5297 }
5298 }
5299
5300 if (holes <= 0) {
5301 WepMenu.board.cursor = 0;
5302 WepMenu.mode = WEP_MENU_ATTACH_WEAPON;
5303 return;
5304 }
5305
5306 if (moved) {
5307 return;
5308 }
5309
5310 if (GamePad.Down(PAD_CROSS)) {
5311 if (holes <= 0) {
5312 ComMenuSePlay(MENU_SOUND_REFUSE);
5313 return;
5314 }
5315
5316 int hole = WepMenu.board.cursor;
5317
5318 if (BtlHaveItemPt->item_no < ITEM_ATTACH_START) {
5319 if (weapon->attach[hole].item_no <= 0) {
5320 ComMenuSePlay(MENU_SOUND_REFUSE);
5321 return;
5322 }
5323
5324 ComMenuSePlay(SE_ATTACHMENT_REMOVE);
5325 s16 held = BtlHaveItemPt->item_no;
5326 s16 item_no = weapon->attach[hole].item_no;
5327 MenuDataSwap(&WepMenu.board.held_attach, &weapon->attach[hole]);
5328 BtlHaveItemPt->item_no = item_no;
5329 weapon->attach[hole].item_no = held;
5330 BtlHaveItemPt->from_slot = WepMenu.board.cursor;
5331 BtlHaveItemPt->from_page = WEP_MENU_ATTACH_SOCKETS;
5332 WEAPON_HAVE total;
5333 WeaponAllValueSet(weapon, &total, 0);
5334 WeaponMenuCheckElemValue(weapon, &total);
5335 return;
5336 }
5337
5338 WEAPON_DATA *data = GetWeaponData(weapon->item_no);
5339 int socket = data->hole[hole];
5340
5341 if (BtlHaveItemPt->item_no == ITEM_ATTACH_SYNTHESIS_SPHERE && socket != 2) {
5342 ComMenuSePlay(MENU_SOUND_REFUSE);
5343 return;
5344 }
5345
5346 ComMenuSePlay(SE_ATTACHMENT_SET);
5347 s16 item_no = weapon->attach[hole].item_no;
5348 s16 held = BtlHaveItemPt->item_no;
5349 MenuDataSwap(&weapon->attach[hole], &WepMenu.board.held_attach);
5350 weapon->attach[hole].item_no = held;
5351 BtlHaveItemPt->item_no = item_no;
5352 BtlHaveItemPt->from_slot = WepMenu.board.cursor;
5353 BtlHaveItemPt->from_page = WepMenu.mode;
5354 WEAPON_HAVE total;
5355 WeaponAllValueSet(weapon, &total, 0);
5356 WeaponMenuCheckElemValue(weapon, &total);
5357 return;
5358 }
5359
5360 if (GamePad.Down(PAD_CIRCLE)) {
5361 ComMenuSePlay(MENU_SOUND_REFUSE);
5362 WepAttachHaveCancel();
5363 return;
5364 }
5365
5366 if (GamePad.Down(PAD_RIGHT)) {
5367 if (WepMenu.board.cursor < holes - 1) {
5368 WepMenu.board.cursor++;
5369
5370 if (WepMenu.board.cursor <= 0) {
5371 WepMenu.board.cursor = 0;
5372 }
5373 } else {
5374 WepMenu.mode = WEP_MENU_ATTACH_BOARD;
5375 WepMenu.board.cursor = WepMenu.board.top_row * 5;
5376 }
5377 } else if (GamePad.Down(PAD_SQUARE)) {
5378 ComMenuSePlay(MENU_SOUND_REFUSE);
5379 } else if (GamePad.Down(PAD_DOWN)) {
5380 WepMenu.mode = WEP_MENU_ATTACH_TAGS;
5381 WepMenu.tag_row = WEP_TAG_ROW_DURABILITY;
5382 }
5383}
5384
5385s32 WeaponMenuSelectKeyLockFlag;
5386
5394static void WeaponMenuAttachKey() {
5395 if (PersonalBoardKey()) {
5396 if (WepMenu.sockets_enabled) {
5397 WepMenu.mode = WEP_MENU_ATTACH_SOCKETS;
5398 WepMenu.board.cursor = GetWeaponHoleNum(GetNowSelectWeapon()->item_no) - 1;
5399 } else {
5400 WepMenu.mode = WEP_MENU_ATTACH_WEAPON;
5401 }
5402 } else if (GamePad.Down(PAD_CROSS)) {
5403 switch (WepMenu.board.cursor_area) {
5404 case PERSONAL_BOARD_AREA_TRASH:
5405 InitHaveData(BtlHaveItemPt);
5406 InitHaveAttach(&WepMenu.board.held_attach);
5407 ComMenuSePlay(MENU_SOUND_REFUSE);
5408 break;
5409 case PERSONAL_BOARD_AREA_CELLS: {
5410 DNG_CONSUMABLE *items = BtlMenuStatusPt->consumable_items;
5411 ATTACH_LIST *slot = (ATTACH_LIST *) &items[WepMenu.board.cursor];
5412
5413 if (slot->item_no >= ITEM_ATTACH_START || BtlHaveItemPt->item_no >= ITEM_ATTACH_START) {
5414 ComMenuSePlay(MENU_SOUND_CONFIRM);
5415 s16 held = BtlHaveItemPt->item_no;
5416 s16 item_no = slot->item_no;
5417 MenuDataSwap(slot, &WepMenu.board.held_attach);
5418 BtlHaveItemPt->item_no = item_no;
5419 slot->item_no = held;
5420 BtlHaveItemPt->from_slot = WepMenu.board.cursor;
5421 BtlHaveItemPt->from_page = WEP_MENU_ATTACH_BOARD;
5422
5423 if (BtlHaveItemPt->item_no >= ITEM_ATTACH_START) {
5424 WepMenu.sockets_enabled = true;
5425 } else {
5426 InitHaveData(BtlHaveItemPt);
5427 InitHaveAttach(&WepMenu.board.held_attach);
5428 }
5429 } else {
5430 ComMenuSePlay(MENU_SOUND_REFUSE);
5431 }
5432
5433 break;
5434 }
5435 }
5436 } else if (GamePad.Down(PAD_CIRCLE)) {
5437 ComMenuSePlay(MENU_SOUND_REFUSE);
5438 WepAttachHaveCancel();
5439 } else if (GamePad.Down(PAD_SQUARE)) {
5440 SeitonAttachBoard((ATTACH_LIST *) BtlMenuStatusPt->consumable_items);
5441 ComMenuSePlay(MENU_SOUND_CONFIRM);
5442 }
5443}
5444
5445#ifdef PAL
5446void RepairAndLevelUpDraw(int x, int y, int alpha) {
5447 int u;
5448 int v;
5449
5450 float widths[7] = {10.7f, 10.7f, 10.7f, 15.3f, 11.8f, 12.2f, 12.3f};
5451 MenuHelpWinDraw(x - 10, y, widths[BtlMenuNowLang], 2.2f, alpha);
5452 int row_y = y + 0xE;
5453 MenuTextureReload(BtlMenuReadBlock);
5454 u8 items[2] = {ITEM_REPAIR_POWDER, ITEM_POWERUP_POWDER};
5455 u8 shift[7] = {0, 0, 0, 58, 8, 22, 22};
5456
5457 for (int i = 0; i < 2; i++) {
5458 int count;
5459 int item_no = items[i];
5460 count = GetNowItemNum(item_no, MenuItemPackPt);
5461 CTexture *icon = RetCTex((u8) item_no, u, v);
5462 DrawMenu2DSprite(icon, CRect_i_(x + 0x10, row_y, 0x20, 0x20), CRect_i_(u, v, 0x20, 0x20), alpha);
5463 DrawMenu2DSprite(BtStatus, CRect_i_(x + 0x9A + shift[BtlMenuNowLang], row_y + 8, 0x10, 0x10), CRect_i_(0x60, 0x58, 0x10, 0x10), alpha);
5464 int number_x = x + 0xC0 + shift[BtlMenuNowLang];
5465
5466 if (count / 10 > 0) {
5467 number_x += NumberSprite[1].width >> 1;
5468 }
5469
5470 DrawMenuNumber(count, number_x, row_y + 8, StayTex, NumberSprite[1], 2, alpha);
5471 row_y += 0x22;
5472 }
5473
5474 MenuTextureReload(CommonMenuMes3.tex_block);
5475
5476 if (BtlMenuNowLang > LANG_JAPANESE) {
5477 s8 count_shift[6] = {20, 20, 0, 12, -6, -4};
5478 int name_x = x + 0x36;
5479 int count_x;
5480 CommonMenuMes3.line_pos[0].x = name_x;
5481 CommonMenuMes3.line_pos[0].y = y + 0xC;
5482 count_x = name_x + count_shift[BtlMenuNowLang - 1];
5483 CommonMenuMes3.line_pos[1].x = count_x;
5484 CommonMenuMes3.line_pos[1].y = y + 0x1C;
5485 CommonMenuMes3.line_pos[2].x = name_x;
5486 CommonMenuMes3.line_pos[2].y = y + 0x2E;
5487 CommonMenuMes3.line_pos[3].x = count_x;
5488 CommonMenuMes3.line_pos[3].y = y + 0x3E;
5489 }
5490
5491 CommonMenuMes3.stay_frame = false;
5492
5493 if (CommonMenuMes3.mes_made != 0x1A7) {
5494 CommonMenuMes3.MakeMesWin(0x1A7);
5495 }
5496
5497 CommonMenuMes3.edge_alpha = alpha;
5498 CommonMenuMes3.Step();
5499 CommonMenuMes3.DrawMesWin();
5500}
5501#else
5502void RepairAndLevelUpDraw(int x, int y, int alpha) {
5503 int u;
5504 int v;
5505
5506 MenuHelpWinDraw(x - 10, y, 10.7f, 2.2f, alpha);
5507 int row_y = y + 0xE;
5508 MenuTextureReload(BtlMenuReadBlock);
5509 int items[2] = {ITEM_REPAIR_POWDER, ITEM_POWERUP_POWDER};
5510
5511 for (int i = 0; i < 2; i++) {
5512 int count;
5513 int item_no = items[i];
5514 count = GetNowItemNum(item_no, MenuItemPackPt);
5515 CTexture *icon = RetCTex(item_no, u, v);
5516 DrawMenu2DSprite(icon, CRect_i_(x + 0x10, row_y, 0x20, 0x20), CRect_i_(u, v, 0x20, 0x20), alpha);
5517 DrawMenu2DSprite(BtStatus, CRect_i_(x + 0x9A, row_y + 8, 0x10, 0x10), CRect_i_(0x60, 0x58, 0x10, 0x10), alpha);
5518 int number_x = x + 0xC0;
5519
5520 if (count / 10 > 0) {
5521 number_x += NumberSprite[1].width >> 1;
5522 }
5523
5524 DrawMenuNumber(count, number_x, row_y + 8, StayTex, NumberSprite[1], 2, alpha);
5525 row_y += 0x22;
5526 }
5527
5528 MenuTextureReload(CommonMenuMes3.tex_block);
5529 int count_x;
5530 int name_x = x + 0x36;
5531 CommonMenuMes3.line_pos[0].x = name_x;
5532 CommonMenuMes3.line_pos[0].y = y + 0xC;
5533 count_x = x + 0x4A;
5534 CommonMenuMes3.line_pos[1].x = count_x;
5535 CommonMenuMes3.line_pos[1].y = y + 0x1C;
5536 CommonMenuMes3.line_pos[2].x = name_x;
5537 CommonMenuMes3.line_pos[2].y = y + 0x2E;
5538 CommonMenuMes3.line_pos[3].x = count_x;
5539 CommonMenuMes3.line_pos[3].y = y + 0x3E;
5540 CommonMenuMes3.stay_frame = false;
5541
5542 if (CommonMenuMes3.mes_made != 0x1A7) {
5543 CommonMenuMes3.MakeMesWin(0x1A7);
5544 }
5545
5546 CommonMenuMes3.edge_alpha = alpha;
5547 CommonMenuMes3.Step();
5548 CommonMenuMes3.DrawMesWin();
5549}
5550#endif
5551
5552void DrawBuildUpWeaponSelect(int x, int y, int cursor) {
5553#ifndef PAL
5554 MenuTextureReload(BtlMenuReadBlock);
5555#endif
5556 float size[7][2] = {
5557 {14.2f, 0.0f},
5558 {13.4f, 1.0f},
5559 {13.4f, 1.0f},
5560 {13.4f, 1.0f},
5561 {13.4f, 1.0f},
5562 {13.4f, 1.0f},
5563 {13.4f, 1.0f}
5564 };
5565 s8 offset[7][2] = {
5566 {-8, 0 },
5567 {-6, -6},
5568 {-6, -6},
5569 {-6, -6},
5570 {-6, -6},
5571 {-6, -6},
5572 {-6, -6}
5573 };
5574 int build;
5575
5576 MenuHelpWinDraw(x - 0xE + offset[BtlMenuNowLang][0], y - 0xC + offset[BtlMenuNowLang][1], size[BtlMenuNowLang][0], size[BtlMenuNowLang][1], 0x80);
5577 CommonMenuMes1.stay_frame = false;
5578 CommonMenuMes1.line_pos[0].x = x;
5579 CommonMenuMes1.line_pos[0].y = y - 6;
5580 y += CommonMenuMes1.char_height;
5581 CommonMenuMes1.line_pos[1].x = x;
5582 CommonMenuMes1.line_pos[1].y = y - 6;
5583 y += 0x1E;
5584 int count = WeaponStatusBuildUp(GetNowSelectWeapon(), build);
5585
5586 for (int i = 0; i < count; i++) {
5587 int selected = 0;
5588
5589 if (i == cursor) {
5590 selected = 1;
5591 }
5592
5593 DrawWeaponNameBoard(x + 0x10, y, selected, 0x80, 0x6E);
5594 int name_x = GetWeaponNamePutX(x + 0x76, CommonMenuMes1.GetMesWidth_system(CommonMenuMes1.mes_no[i]));
5595
5596 if (i + 2 >= 0 && i + 2 < 10) {
5597 CommonMenuMes1.line_pos[i + 2].x = name_x;
5598 CommonMenuMes1.line_pos[i + 2].y = y + 5;
5599 }
5600
5601 y += 0x26;
5602 }
5603
5604 MenuTextureReload(CommonMenuMes1.tex_block);
5605 CommonMenuMes1.Step();
5606 CommonMenuMes1.DrawMesWin();
5607}
5608
5609void WeaponMenuDraw() {
5610 int alpha;
5611 int attach_mode;
5612 int scratch;
5613 int i;
5614
5615 BtlMenuTexBlockEnter();
5616 alpha = 0x80;
5617
5618 switch (WepMenu.state) {
5619 case WEP_STATE_OPEN:
5620 alpha = WepMenu.counter * 9;
5621
5622 if (alpha > 0x80) {
5623 alpha = 0x80;
5624 }
5625
5626 break;
5627 case WEP_STATE_CLOSE:
5628 alpha = 0x80 - WepMenu.counter * 9;
5629
5630 if (alpha < 0) {
5631 alpha = 0;
5632 }
5633
5634 break;
5635 }
5636
5637 attach_mode = 0;
5638
5639 switch (WepMenu.mode) {
5640 case WEP_MENU_ATTACH_WEAPON:
5641 case WEP_MENU_ATTACH_SOCKETS:
5642 case WEP_MENU_ATTACH_BOARD:
5643 case WEP_MENU_ATTACH_TAGS:
5644 attach_mode = 1;
5645 case WEP_MENU_LIST:
5646 case WEP_MENU_ACTION:
5647 case WEP_MENU_ELEMENT:
5648 case WEP_MENU_LEVELUP_CONFIRM:
5649 case WEP_MENU_STATUS_BREAK_CONFIRM:
5650 case WEP_MENU_BUILDUP_SELECT:
5651 case WEP_MENU_BUILDUP_CONFIRM:
5652 case WEP_MENU_BUILDUP_PREVIEW:
5653 for (i = 0; i < 6; i++) {
5654 int target = (SysChara[i].chara - WepMenu.chara) * 0x6E + 0x10E;
5655 SysChara[i].x += ((float) target - SysChara[i].x) / 4.0f;
5656
5657 if (attach_mode == 0 || i == WepMenu.chara) {
5658 CTexture *face = MenuCharaFace;
5659 scratch = 0;
5660 int face_chara = SysChara[i].chara;
5661 int v = face_chara * 0x6A;
5662
5663 if (face_chara > 2) {
5664 scratch = 0x6A;
5665 v = (face_chara - 3) * 0x6A;
5666 }
5667
5668 if (BtlMenuStatusPt->party_size <= i) {
5669 face = BtStatus;
5670 v = scratch = 0x8C;
5671 }
5672
5673 DrawMenu2DSprite(face, CRect_i_(SysChara[i].x, 0xE, 0x64, 0x64), CRect_i_(scratch, v, 0x6A, 0x6A), alpha, alpha, alpha, alpha);
5674 }
5675 }
5676
5677 FadeTexX(0xDC, 0x32, 0x172, 0x32, "frame_image", 0);
5678
5679 if (attach_mode == 0) {
5680 static int ct = 0;
5681 scratch = alpha;
5682
5683 if (WepMenu.mode == WEP_MENU_LIST) {
5684 ct++;
5685
5686 if (ct > 1000000) {
5687 ct = 0;
5688 }
5689 } else {
5690 scratch = 0;
5691 }
5692
5693 if (ct % 50 < 30) {
5694 i = ct % 30 / 10 * 2;
5695 CRect_i_ arrow(0x60, 0x68, 10, 0x18);
5696 DrawMenu2DSprite(BtStatus, CRect_i_(0x102 - i, 0x48, arrow.width, arrow.height), arrow, scratch);
5697 arrow.x += arrow.width;
5698 DrawMenu2DSprite(BtStatus, CRect_i_(i + 0x174, 0x48, arrow.width, arrow.height), arrow, scratch);
5699 }
5700 }
5701
5702 break;
5703 }
5704
5705 int target_x;
5706 float target_depth;
5707
5708 switch (WepMenu.mode) {
5709 case WEP_MENU_LIST:
5710 case WEP_MENU_ACTION:
5711 case WEP_MENU_ELEMENT:
5712 case WEP_MENU_LEVELUP_CONFIRM:
5713 case WEP_MENU_STATUS_BREAK_CONFIRM:
5714 case WEP_MENU_BUILDUP_SELECT:
5715 case WEP_MENU_BUILDUP_CONFIRM:
5716 case WEP_MENU_BUILDUP_PREVIEW:
5717 target_x = 0xE8 - WepMenu.weapon_slot * 0xD6;
5718 target_depth = 2.0f + 16.0f * -WepMenu.weapon_slot;
5719 break;
5720 case WEP_MENU_ATTACH_WEAPON:
5721 case WEP_MENU_ATTACH_SOCKETS:
5722 case WEP_MENU_ATTACH_BOARD:
5723 case WEP_MENU_ATTACH_TAGS: {
5724 int slot = WepMenu.weapon_slot;
5725 target_x = (int) (80.0f - (float) (slot * 0xD6));
5726 target_depth = 2.0f + (-11.0f + 16.0f * -slot);
5727 break;
5728 }
5729 }
5730
5731 WeaponPos += ((float) target_x - WeaponPos) / 4.0f;
5732 WepPolyPos += (target_depth - WepPolyPos) / 4.0f;
5733 scratch = alpha;
5734
5735 switch (WepMenu.state) {
5736 case WEP_STATE_UNK_3:
5737 scratch = alpha - 9;
5738 break;
5739 case WEP_STATE_CHARA_CHANGE:
5740 scratch = WepMenu.counter * 5;
5741 break;
5742 case WEP_STATE_OPEN:
5743 case WEP_STATE_CLOSE:
5744 scratch = alpha;
5745 break;
5746 }
5747
5748 if (scratch < 0) {
5749 scratch = 0;
5750 }
5751
5752 if (scratch > 0x80) {
5753 scratch = 0x80;
5754 }
5755
5756 target_x = (int) WeaponPos;
5757 target_depth = WepPolyPos;
5758 BtlWeaponDraw(target_x, target_depth, WepMenu.chara, scratch);
5759
5760 if (attach_mode == 0) {
5761#ifdef PAL
5762 u8 repair_x[7] = {78, 78, 78, 26, 64, 64, 66};
5763 RepairAndLevelUpDraw(repair_x[BtlMenuNowLang], 0x164, alpha);
5764#else
5765 RepairAndLevelUpDraw(0x4E, 0x144, alpha);
5766#endif
5767 }
5768
5769 int dialog_pos = 0x70;
5770#ifndef PAL
5771 MenuTextureReload(BtlMenuReadBlock);
5772#endif
5773 WEP_BUILDUP_INFO builds[4];
5774
5775 switch (WepMenu.mode) {
5776 case WEP_MENU_LEVELUP_CONFIRM:
5777 case WEP_MENU_BUILDUP_CONFIRM:
5778#ifdef PAL
5779 MenuTextureReload(BtlMenuReadBlock);
5780#endif
5781 DrawDngYesNoDialog(0x88, 0xDD, 0x80);
5782 MenuHelpWinDraw(0x46, 0x8C, 10.0f, 1.4f, 100);
5783 CommonMenuMes1.stay_frame = false;
5784 CommonMenuMes1.edge_alpha = 0x80;
5785 MenuTextureReload(CommonMenuMes1.tex_block);
5786 DrawMenuClsMes(&CommonMenuMes1, 0x58, 0x92);
5787 break;
5788 case WEP_MENU_STATUS_BREAK_CONFIRM:
5789#ifdef PAL
5790 MenuTextureReload(BtlMenuReadBlock);
5791#endif
5792 DrawDngYesNoDialog(0x88, 0xF3, 0x80);
5793 CommonMenuMes1.auto_pos = MES_POS_NONE;
5794 CommonMenuMes1.stay_frame = true;
5795 CommonMenuMes1.edge_alpha = 0x80;
5796 DrawMenuClsMes(&CommonMenuMes1, 0x50, 0x98);
5797 break;
5798 case WEP_MENU_BUILDUP_PREVIEW:
5799 AllFadeForMenu(0x40);
5800#ifdef PAL
5801 MenuTextureReload(BtlMenuReadBlock);
5802#endif
5803 DrawBtlMenuLRCursor(0x158, 0x6E, 0xD4, alpha);
5804 EnableBuildUpModel(builds, GetNowSelectWeapon());
5805#ifdef PAL
5806 MenuTextureReload(BtlMenuExtBlock);
5807#endif
5808 DrawWeaponTagBoard(0x16C, 0x78, GetNowSelectWeapon(), 1, builds[WepMenu.board.cursor].weapon_no, 0x80);
5809 case WEP_MENU_BUILDUP_SELECT:
5810#ifdef PAL
5811 MenuTextureReload(BtlMenuExtBlock);
5812#endif
5813 DrawBuildUpWeaponSelect(0x58, 0x9C, WepMenu.board.cursor);
5814 break;
5815 case WEP_MENU_ELEMENT:
5816#ifdef PAL
5817 MenuTextureReload(BtlMenuExtBlock);
5818#endif
5819 DrawWeaponTagBoard(0x18A, 0x64, GetNowSelectWeapon(), 0, 0, 0x80);
5820 case WEP_MENU_ACTION:
5821#ifdef PAL
5822 MenuTextureReload(BtlMenuExtBlock);
5823#endif
5824 dialog_pos = 0x70;
5825
5826 if (GetNowSelectWeapon() != NULL) {
5827 DrawWeaponSelectDialog(dialog_pos, dialog_pos, scratch);
5828 }
5829
5830 break;
5831 case WEP_MENU_LIST:
5832 if (BtlMenuStatusPt->party_size > 1) {
5833 DrawBtlMenuLRCursor(0xE6, 0x12, 0x96, alpha);
5834 }
5835
5836 break;
5837 case WEP_MENU_ATTACH_WEAPON:
5838 case WEP_MENU_ATTACH_SOCKETS:
5839 case WEP_MENU_ATTACH_BOARD:
5840 case WEP_MENU_ATTACH_TAGS:
5841 MenuTextureReload(BtlMenuReadBlock);
5842 DrawPersonalBoard(0x154, 0x78, WepMenu.board.page, alpha, 0);
5843 CommonTrushDraw(0x232, 0x10C, alpha);
5844
5845 if (BtlHaveItemPt->item_no >= ITEM_ATTACH_START) {
5846 MenuTextureReload(MenuShadowReadBlock);
5847 DrawMenuVibeItem((int) SysCur[0], (int) SysCur[1], 2, -0xC, 0x80);
5848 }
5849
5850 break;
5851 }
5852
5853 RECT frame;
5854 // The weapon is read with the slot as it was before the clamp below, which fixes only the stored slot.
5855 int slot = WepMenu.weapon_slot;
5856
5857 if (slot < 0) {
5858 WepMenu.weapon_slot = 0;
5859 }
5860
5861 if (slot > 9) {
5862 WepMenu.weapon_slot = 9;
5863 }
5864
5865 int holes = GetWeaponHoleNum(DngWepHavePt[slot].item_no);
5866 s16 cursor_pos[12][2] = {
5867 {0xC0, 0xA5},
5868 {0x50, 0 },
5869 {0x16E, 0 },
5870 {0x68, 0 },
5871 {0x68, 0 },
5872 {0x4E, 0 },
5873 {0x68, 0 },
5874 {0x4E, 0 },
5875 {0x58, 0xAA},
5876 {0, 0xB8},
5877 {0, 0 },
5878 {0, 0 }
5879 };
5880 s16 row = (s16) WepMenu.board.cursor * 0x1A;
5881 cursor_pos[1][1] = dialog_pos + row;
5882 cursor_pos[2][1] = WepMenu.element * 0x18 + 0x86;
5883 s16 dialog_y = row + 0xDC;
5884 cursor_pos[3][1] = dialog_y;
5885 cursor_pos[4][1] = row + 0xF2;
5886 s16 build_y = CommonMenuMes1.char_height + ((s16) WepMenu.board.cursor * 0x26 + 0xBA);
5887 cursor_pos[5][1] = build_y;
5888 cursor_pos[6][1] = dialog_y;
5889 cursor_pos[7][1] = build_y;
5890 cursor_pos[9][0] = (0x90 - holes * 0x12) + (s16) WepMenu.board.cursor * 0x2A;
5891 int cursor_x = cursor_pos[WepMenu.mode][0];
5892 int cursor_y = cursor_pos[WepMenu.mode][1];
5893
5894 if (WepMenu.state == WEP_STATE_SCRAP_PROMPT) {
5895 cursor_x = 0xB4;
5896 cursor_y = dialog_pos + 0x2E;
5897 }
5898
5899 if (WepMenu.state == WEP_STATE_SCRAP_CONFIRM) {
5900 cursor_x = 0x171;
5901 cursor_y = WepMenu.confirm[0] * 0x1A + 0xBE;
5902 }
5903
5904 RECT frames[12] = {
5905 {0xCD, 0x64, 0xCC, 0xC9},
5906 {0, 0, 0x60, 0x18},
5907 {0, 0, 0xC4, 0x18},
5908 {0, 0, 0x60, 0x18},
5909 {0, 0, 0x60, 0x18},
5910 {0, 0, 0xC0, 0x20},
5911 {0, 0, 0x60, 0x18},
5912 {0, 0, 0xC0, 0x20},
5913 {0, 0, 0x6E, 0x6E},
5914 {0, 0, 0x28, 0x28},
5915 {0, 0, 0x26, 0x26},
5916 {0xD8, 0x76, 0xB8, 0x98}
5917 };
5918 frames[1].x = cursor_x + 0x19;
5919 frames[1].y = cursor_y - 6;
5920 frames[2].x = cursor_x + 0x1A;
5921 frames[2].y = cursor_y - 6;
5922 frames[3].x = cursor_x + 0x18;
5923 frames[3].y = cursor_y - 6;
5924 frames[4].x = cursor_x + 0x18;
5925 frames[4].y = cursor_y - 6;
5926 frames[5].x = cursor_x + 0x18;
5927 frames[5].y = cursor_y - 8;
5928 frames[6].x = cursor_x + 0x18;
5929 frames[6].y = cursor_y - 6;
5930 frames[7].x = cursor_x + 0x18;
5931 frames[7].y = cursor_y - 8;
5932 frames[8].x = cursor_x + 0x12;
5933 frames[8].y = cursor_y - 0x18;
5934 frames[9].x = cursor_x + 0xC;
5935 frames[9].y = cursor_y - 8;
5936 frames[10].x = cursor_x + 0xC;
5937 frames[10].y = cursor_y - 8;
5938 frame = frames[WepMenu.mode];
5939 WEAPON_HAVE *selected = GetNowSelectWeapon();
5940
5941 if (selected != NULL && selected->item_no < ITEM_WEAPON_START) {
5942 frame = frames[11];
5943 }
5944
5945 if (WepMenu.state == WEP_STATE_SCRAP_PROMPT) {
5946 frame.x = cursor_x + 0x19;
5947 frame.y = cursor_y - 4;
5948 frame.width = 0x60;
5949 frame.height = 0x18;
5950 }
5951
5952 switch (WepMenu.mode) {
5953 case WEP_MENU_ACTION:
5954 if (WepMenu.board.cursor >= WEP_ACTION_LEVELUP) {
5955 scratch = 0;
5956 int options = NowWeaponStatusValue(&DngWepHavePt[WepMenu.weapon_slot]);
5957
5958 for (int i = 4; WepMenu.board.cursor >= i; i++) {
5959 if (options & (1 << (i - 3))) {
5960 scratch += 0x1A;
5961 }
5962 }
5963
5964 cursor_y = dialog_pos + 0x4E + scratch;
5965 frame.y = cursor_y - 6;
5966 }
5967
5968 break;
5969 case WEP_MENU_BUILDUP_SELECT:
5970 case WEP_MENU_ATTACH_SOCKETS:
5971 break;
5972 case WEP_MENU_ATTACH_BOARD:
5973 switch (WepMenu.board.cursor_area) {
5974 case PERSONAL_BOARD_AREA_CELLS: {
5975 int cell = WepMenu.board.cursor;
5976 cursor_x = cell % 5 * 0x28 + 0x154;
5977 cell -= WepMenu.board.top_row * 5;
5978 cursor_y = cell / 5 * 0x28 + 0x7E;
5979 break;
5980 }
5981 case PERSONAL_BOARD_AREA_TRASH:
5982 cursor_x = 0x220;
5983 cursor_y = 0x110;
5984 break;
5985 }
5986
5987 frame.x = cursor_x + 0xC;
5988 frame.y = cursor_y - 8;
5989 frame.height = 0x26;
5990 frame.width = 0x26;
5991 break;
5992 case WEP_MENU_ATTACH_TAGS: {
5993 int sel = WepMenu.tag_row;
5994
5995 switch (WepMenu.tag_page) {
5996 case WEP_TAG_STATUS:
5997 if (sel < 2) {
5998 cursor_x = 0x24;
5999 cursor_y = sel * 0x14 + 0x114;
6000 frame.width = 0xCA;
6001 } else {
6002 cursor_x = 0x2A;
6003 cursor_y = (sel - 2) * 0x10 + 0x148;
6004 frame.width = 0xC4;
6005 }
6006
6007 break;
6008 case WEP_TAG_ELEMENT:
6009 cursor_x = 0x2A;
6010 cursor_y = sel * 0x18 + 0x112;
6011 frame.width = 0xC4;
6012 break;
6013 case WEP_TAG_VS_MONSTER:
6014 cursor_x = sel / 5 * 0x68 + 0x28;
6015 cursor_y = sel % 5 * 0x18 + 0x112;
6016 frame.width = 0x66;
6017 break;
6018 }
6019
6020 frame.x = cursor_x + 0x1C;
6021 frame.y = cursor_y - 6;
6022 frame.height = 0x18;
6023 break;
6024 }
6025 }
6026
6027 DNG_CONSUMABLE *consumables = BtlMenuStatusPt->consumable_items;
6028
6029 if (WepMenu.mode <= WEP_MENU_LIST) {
6030 scratch = 0x40;
6031 } else if (BtlHaveItemPt->item_no >= ITEM_ATTACH_START) {
6032 cursor_x += 0x12;
6033 cursor_y += 0xE;
6034 scratch = 0x80;
6035 } else if ((WepMenu.mode == WEP_MENU_ATTACH_SOCKETS && DngWepHavePt[slot].attach[WepMenu.board.cursor].item_no >= ITEM_ATTACH_START) || (WepMenu.mode == WEP_MENU_ATTACH_BOARD && consumables[WepMenu.board.cursor].id >= ITEM_ATTACH_START)) {
6036 cursor_x += 10;
6037 cursor_y += 0x18;
6038 scratch = 0x60;
6039 } else {
6040 scratch = 0x40;
6041 }
6042
6043 SysCur[0] += ((float) cursor_x - SysCur[0]) / 4.0f;
6044 SysCur[1] += ((float) cursor_y - SysCur[1]) / 4.0f;
6045
6046 switch (WepMenu.state) {
6047 case WEP_STATE_OPEN:
6048 case WEP_STATE_CLOSE:
6049 case WEP_STATE_CHARA_CHANGE:
6050 case WEP_STATE_LEVELUP_EFFECT:
6051 case WEP_STATE_STATUS_BREAK_EFFECT:
6052 case WEP_STATE_BUILDUP_EFFECT:
6053 case WEP_STATE_REPAIR_EFFECT:
6054 CommonMenuMes1.auto_pos = MES_POS_NONE;
6055 return;
6056 case WEP_STATE_WARNING:
6057 case WEP_STATE_SCRAP_REFUSED:
6058 CommonMenuMes1.auto_pos = MES_POS_CENTRE;
6059 MenuTextureReload(CommonMenuMes1.tex_block);
6060 CommonMenuMes1.Step();
6061 CommonMenuMes1.DrawMesWin();
6062 return;
6063 default: {
6064 int shadow = 0;
6065
6066 if (WepMenu.mode == WEP_MENU_LIST) {
6067 shadow = 1;
6068 }
6069
6070 if (WepMenu.state == WEP_STATE_SCRAP_CONFIRM) {
6071 DrawDngYesNoDialog(0x190, 0xBE, 0x80);
6072 s8 offset[7][2] = {
6073 {-20, -60},
6074 {-24, -68},
6075 {-24, -68},
6076 {-24, -68},
6077 {-24, -68},
6078 {-24, -68},
6079 {-24, -68}
6080 };
6081 CommonMenuMes1.auto_pos = MES_POS_NONE;
6082 CommonMenuMes1.text_x = offset[BtlMenuNowLang][0] + 0x190;
6083 CommonMenuMes1.text_y = offset[BtlMenuNowLang][1] + 0xBE;
6084 MenuTextureReload(CommonMenuMes1.tex_block);
6085 CommonMenuMes1.Step();
6086 CommonMenuMes1.DrawMesWin();
6087 }
6088
6089 DrawMenuWaku(frame.x, frame.y, frame.width, frame.height, shadow, StayTex, 0x80);
6090 int big = 1;
6091
6092 if (scratch >= 0x80) {
6093 big = 0;
6094 }
6095
6096 DrawMenuObjectVibe((int) SysCur[0], (int) SysCur[1], big, scratch);
6097 return;
6098 }
6099 }
6100}
6101
6112static int ItemTrushKey(int *thrown, int *thrown_vol, int slot) {
6113 int swapped = 0;
6114 int page = ItemMenuMode.board.page;
6115 int kind = WhatIsKindofItem(BtlHaveItemPt->item_no);
6116 s16 held = BtlHaveItemPt->item_no;
6117 s16 item_no;
6118
6119 switch (page) {
6120 case BOARD_PAGE_ITEM:
6121 if (!kind || kind == BOARD_PAGE_NONE) {
6122 MenuDataSwap(&MenuItemPackPt->item[MenuItemPackPt->num + slot], &ItemMenuMode.board.held_item.item_no);
6123 MenuDataSwap(&ItemMenuMode.board.held_item.volume, &MenuItemPackPt->item_vol[MenuItemPackPt->num + slot]);
6124 swapped = 1;
6125 }
6126
6127 break;
6128 case BOARD_PAGE_WEAPON:
6129 if (kind == BOARD_PAGE_WEAPON || kind == BOARD_PAGE_NONE) {
6130 int owner = -1;
6131 WEAPON_HAVE *weapon;
6132 int equip = WhoIsWeaponEquip(held);
6133
6134 if (equip < 0) {
6135 for (int i = 0; i < 6; i++) {
6136 CDngStatusData *status = BtlMenuStatusPt;
6137 WEAPON_HAVE *row = status->chara_weapons[i];
6138 weapon = &row[10];
6139
6140 if (weapon != NULL && weapon->item_no >= ITEM_WEAPON_START) {
6141 owner = (s8) GetWeaponData(weapon->item_no)->owner;
6142 break;
6143 }
6144 }
6145 } else {
6146 CDngStatusData *status = BtlMenuStatusPt;
6147 WEAPON_HAVE *row = status->chara_weapons[equip];
6148 weapon = &row[10];
6149
6150 if (weapon != NULL) {
6151 owner = equip;
6152 }
6153 }
6154
6155 int is_default = 0;
6156
6157 for (int chara = 0; chara < 6; chara++) {
6158 int default_no = GetDefaultWeaponNo(chara);
6159
6160 if (ItemMenuMode.board.weapon.item_no == default_no || ItemMenuMode.board.weapon.item_no == default_no + 1) {
6161 is_default = 1;
6162 }
6163 }
6164
6165 int allowed = 1;
6166
6167 if (ItemMenuMode.board.held_equipped_slot >= 0) {
6168 allowed = 0;
6169 }
6170
6171 if (is_default) {
6172 allowed = 0;
6173 }
6174
6175 if (equip >= 0 && owner != equip && owner >= 0) {
6176 allowed = 0;
6177 }
6178
6179 if (allowed) {
6180 item_no = weapon->item_no;
6181 MenuDataSwap(weapon, &ItemMenuMode.board.weapon);
6182 BtlHaveItemPt->item_no = item_no;
6183 weapon->item_no = held;
6184 swapped = 1;
6185 } else {
6186 swapped = 0;
6187 }
6188 }
6189
6190 break;
6191 case BOARD_PAGE_ATTACH:
6192 if (kind == BOARD_PAGE_ATTACH || kind == BOARD_PAGE_NONE) {
6193 DNG_CONSUMABLE *items = BtlMenuStatusPt->consumable_items;
6194 ATTACH_LIST *attach = (ATTACH_LIST *) &items[slot] + 40;
6195 item_no = attach->item_no;
6196 MenuDataSwap(attach, &ItemMenuMode.board.held_attach);
6197 BtlHaveItemPt->item_no = item_no;
6198 attach->item_no = held;
6199 swapped = 1;
6200 }
6201
6202 break;
6203 }
6204
6205 return swapped;
6206}
6207
6208void DrawTrushItem() {
6209 int items[7];
6210 int values[7];
6211
6212 for (int i = 0; i < 7; i++) {
6213 items[i] = 0;
6214 values[i] = 0;
6215 }
6216
6217 if (CheckItemThrow(items, values) == 0 && ItemMenuMode.overflow == 0) {
6218 return;
6219 }
6220
6221 int page = ItemMenuMode.board.page;
6222 int count[3] = {3, 1, 3};
6223 int first[3] = {0, 3, 4};
6224 int entry = first[page];
6225 int y = 0x7E;
6226 MenuTextureReload(ItemMenuWeaponIconReadBlock);
6227 static int ncnt = 0;
6228 int bright = (int) (112.0f + 48.0f * sinf(PI * (float) (ncnt - 0x3C) / 60.0f));
6229
6230 for (int i = 0; i < 3; i++) {
6231 if ((ItemMenuMode.overflow_pages & (1 << (i + 1))) && page == i) {
6232 for (int j = 0; j < ItemMenuMode.overflow_count[i]; j++, entry++) {
6233 DrawMenu2DSprite(CharaStatus, CRect_i_(0x138, y, 0x2A, 0x29), CRect_i_(0xC2, 0xD6, 0x2A, 0x2A), bright, bright, bright, 0x80);
6234 DrawIconParts(items[entry], 0x13C, y + 6, 0, 0x280, 0x80, values[entry]);
6235 y += 0x2E;
6236 }
6237
6238 break;
6239 }
6240 }
6241
6242 (void) count;
6243 ncnt++;
6244
6245 if (ncnt > 0x3B) {
6246 ncnt = 0;
6247 }
6248
6249 MenuTextureReload(AtoraNameMes.tex_block);
6250
6251 if (AtoraNameMes.mes_made != 0xBB) {
6252 AtoraNameMes.MakeMesWin(0xBB);
6253 }
6254
6255 AtoraNameMes.stay_frame = true;
6256 AtoraNameMes.edge_alpha = 0x80;
6257 DrawMenuClsMes(&AtoraNameMes, 0x34, 0x152);
6258}
6259
6267static void ExitItemSelect() {
6268 CommonMenuMes3.rows = 3;
6269 CommonMenuMes3.narrow_gaiji = false;
6270 CommonMenuMes3.char_width = 11;
6271 AtoraNameMes.stay_frame = false;
6272 AtoraNameMes.auto_pos = MES_POS_NONE;
6273 CMenuCursor *cursor = SaveData->GetMenuCursor();
6274
6275 if (cursor->reset_pos == 0) {
6276 SetCursorPos(cursor, 0, ItemMenuMode.board.cursor);
6277 cursor->mode[0] = ItemMenuMode.mode;
6278 SetCursorChara(cursor, ItemMenuMode.board.page);
6279 }
6280}
6281
6289static void StartBGReadItemMenuWepIcon(u_long128 *buffer, int &size) {
6290 StartReadBG();
6291 size = LoadFileBGMenuData("wepchara.img", buffer);
6292 ItemMenuAlreadyReadWepIconTexFlag = 0;
6293}
6294
6295void ReadSyncItemMenuWepIcon() {
6296 BG_READ_INFO *file = GetReadBGFile(0);
6297 LOADTEXTURE_INFO2 textures[3] = {
6298 {"#frame_image#640#" SCREEN_HEIGHT_STR "#4", 0, 0},
6299 {NULL, 0, 0},
6300 {NULL, 0, 0}
6301 };
6302
6303 textures[0].block_no = ItemMenuWeaponIconReadBlock;
6304 textures[1].name = (char *) file->buffer;
6305 textures[1].block_no = ItemMenuWeaponIconReadBlock;
6306 CharaStatus = TexManager.GetTexture("status", -1);
6307 TexManager.DeleteTextureBlock(ItemMenuWeaponIconReadBlock);
6308 TexManager.CleanUpTextureList();
6309 TexManager.LoadTextureBlockEX(-1, textures);
6310}
6311
6322static void InitItemMode(int mode, int chara) {
6323 CMenuCursor *cursor;
6324 int max;
6325 int thrown[7];
6326
6327 InitPersonalBoardMode((CUserStatus *) BtlMenuStatusPt, &ItemMenuMode.board, PERSONAL_BOARD_ITEM, BOARD_PAGE_ITEM);
6328 ItemMenuMode.mode = ITEM_MENU_BOARD;
6329 ItemMenuMode.chara = chara;
6330 cursor = SaveData->GetMenuCursor();
6331
6332 if (cursor->reset_pos == 0) {
6333 ItemMenuMode.mode = cursor->mode[0];
6334
6335 if (ItemMenuMode.mode < 0 || ItemMenuMode.mode > ITEM_MENU_BOARD) {
6336 ItemMenuMode.mode = ITEM_MENU_BOARD;
6337 }
6338
6339 max = PersonalRetMax(cursor->chara_no);
6340 ItemMenuMode.board.cursor = cursor->pos[0];
6341 ItemMenuMode.board.top_row = ItemMenuMode.board.cursor / 5 - 3;
6342
6343 if (ItemMenuMode.board.top_row < 0) {
6344 ItemMenuMode.board.top_row = 0;
6345 }
6346 } else {
6347 ItemMenuMode.mode = ITEM_MENU_BOARD;
6348 ItemMenuMode.board.cursor = 0;
6349 ItemMenuMode.board.top_row = 0;
6350 max = PersonalRetMax(BOARD_PAGE_ITEM);
6351 }
6352
6353 memset(thrown, 0, sizeof(thrown));
6354
6355 for (int i = 0; i < 3; i++) {
6356 ItemMenuMode.overflow_count[i] = 0;
6357 }
6358
6359 ItemMenuMode.overflow_pages = 0;
6360 ItemMenuMode.overflow = false;
6361
6362 if (CheckItemThrow(thrown, NULL)) {
6363 for (int i = 0; i < 3; i++) {
6364 if (thrown[i] >= ITEM_DUNGEON_START) {
6365 ItemMenuMode.overflow_count[0]++;
6366 }
6367 }
6368
6369 if (thrown[3] >= ITEM_WEAPON_START) {
6370 ItemMenuMode.overflow_count[1]++;
6371 }
6372
6373 for (int i = 0; i < 3; i++) {
6374 if (thrown[i + 4] < ITEM_ATTACH_START) {
6375 break;
6376 }
6377
6378 ItemMenuMode.overflow_count[2]++;
6379 }
6380
6381 for (int i = 0; i < 3; i++) {
6382 if (ItemMenuMode.overflow_count[i] > 0) {
6383 ItemMenuMode.overflow_pages |= 1 << (i + 1);
6384 }
6385 }
6386
6387 for (int i = 2; i >= 0; i--) {
6388 if (ItemMenuMode.overflow_pages & (1 << (i + 1))) {
6389 ItemMenuMode.board.page = i;
6390 }
6391 }
6392
6393 if (ItemMenuMode.board.page == BOARD_PAGE_WEAPON) {
6394 ItemMenuMode.board.cursor = WhoIsWeaponEquip(thrown[3]) * 10;
6395 ItemMenuMode.board.top_row = ItemMenuMode.board.cursor / 5;
6396
6397 if (ItemMenuMode.board.top_row < 0) {
6398 ItemMenuMode.board.top_row = 0;
6399 }
6400
6401 if (ItemMenuMode.board.top_row > 9) {
6402 ItemMenuMode.board.top_row = 9;
6403 }
6404 }
6405
6406 ItemMenuMode.overflow = true;
6407 BtlMenuStatusPt->overflow_flag = true;
6408 }
6409
6410 ItemMenuMode.board.y = 127 - ItemMenuMode.board.top_row * 40;
6411 int pages = max / 5;
6412 ItemMenuMode.board.scroll = 140.0f + 114.0f * ItemMenuMode.board.top_row / pages;
6413 ItemMenuMode.board.cursor_area = PERSONAL_BOARD_AREA_CELLS;
6414 ItemMenuMode.state = ITEM_MENU_STATE_LOADING;
6415 ItemMenuMode.counter = 0;
6416 u_long128 *buffer = BtlMenuReadBuf;
6417 int size;
6418 StartBGReadItemMenuWepIcon(buffer, size);
6419 buffer += (size >> 4) + 1;
6420 ItemMenuCharaReadBuf = MenuCalcBufAlignment(buffer);
6421 BtlHaveItemPt = &ItemMenuMode.board.held_item;
6422 StartLoadCharaMDS(ItemMenuCharaReadBuf, chara, 1);
6423 MenuExTextureReadFlag = MENU_EX_TEX_UNREAD;
6424 memset(&IconAutoGet, -1, sizeof(IconAutoGet));
6425 CommonMenuMes3.Preset(MES_PRESET_NAME);
6426 CommonMenuMes3.mes_made = -1;
6427 CommonMenuMes3.rows = 1;
6428 CommonMenuMes3.char_width = 12;
6429 CommonMenuMes1.mes_made = -1;
6430 AtoraNameMes.value_signed = false;
6431 AtoraNameMes.Preset(MES_PRESET_SYSTEM);
6432 AtoraNameMes.mes_made = -1;
6433 AtoraNameMes.rows = 3;
6434
6435 for (int i = 0; i < 10; i++) {
6436 AtoraNameMes.mes_no[i] = 0;
6437 AtoraNameMes.values[i] = 0;
6438 SetLinePos(&AtoraNameMes, i, -1, -1);
6439 }
6440
6441 AtoraNameMes.char_width = GetMenuCommonFontW(BtlMenuNowLang, -1);
6442 int member = ItemMenuMode.chara;
6443 CDngStatusData *status = BtlMenuStatusPt;
6444 int slot = status->equipped_weapon_slot[member];
6445 WEAPON_HAVE *row = status->chara_weapons[member];
6446 WEAPON_HAVE *weapon = &row[slot];
6447
6448 if (weapon != NULL) {
6449 SetNowEquipWeaponDataForMsg(weapon->item_no, weapon->level);
6450 } else {
6451 SetNowEquipWeaponDataForMsg(0, 0);
6452 }
6453}
6454
6462static void InitItemTrushStart() {
6463 if (ReadBGSync() == 0) {
6464 BattleMenuTexEnter();
6465
6466 if (BtlMenuMode == BATTLE_MENU_MODE_TOWN) {
6467 BtlMenuStatusPt->cur_chara = 0;
6468 }
6469
6470 InitItemMode(0, BtlMenuStatusPt->cur_chara);
6471 BattleMenuFlag = MenuSelect[0] + BTLMENU_STATE_OPEN_OFFSET;
6472 BtlEffectFlag = BTLEFFECT_PAGE_OPEN;
6473 BtlEffectCt = 0.0f;
6474 }
6475}
6476
6477void ExistItemMenu() {
6478 int blocks[3] = {0, 0, -1};
6479
6480 blocks[0] = MenuExtendReadBlock;
6481 blocks[1] = ItemMenuWeaponIconReadBlock;
6482 MenuTextureDelete(blocks);
6483 TexManager.CleanUpTextureList();
6484 BtlMenuTexBlockEnter();
6485
6486 for (int i = 0; i < 6; i++) {
6487 int slot = BtlMenuStatusPt->equipped_weapon_slot[i];
6488
6489 if (0 > slot || slot >= 10) {
6490 EquipDefaultWeapon(i);
6491 }
6492 }
6493
6494 ForBackMenu();
6495}
6496
6504static void ChangeMenuChara() {
6505 if (MenuWepLevelUp.operation_kind < WEP_EFFECT_CURE_HEAL_HP || MenuWepLevelUp.operation_kind > WEP_EFFECT_CURE_POCKET) {
6506 int previous = ItemMenuMode.chara;
6507 int party_size = BtlMenuStatusPt->party_size;
6508
6509 if (GamePad.Down(PAD_L2 | PAD_L1) != 0) {
6510 ItemMenuMode.chara--;
6511
6512 if (ItemMenuMode.chara < 0) {
6513 ItemMenuMode.chara = party_size - 1;
6514 }
6515 }
6516
6517 if (GamePad.Down(PAD_R2 | PAD_R1) != 0) {
6518 ItemMenuMode.chara++;
6519
6520 if (party_size - 1 < ItemMenuMode.chara) {
6521 ItemMenuMode.chara = 0;
6522 }
6523 }
6524
6525 if (previous != ItemMenuMode.chara) {
6526 if (ItemMenuMode.chara <= BtlMenuStatusPt->party_size) {
6527 if (ReadBGSync() != 0) {
6528 BreakReadBG();
6529 }
6530
6531 MenuExTextureReadFlag = StartLoadCharaMDS(ItemMenuCharaReadBuf, ItemMenuMode.chara, 0);
6532 int chara = ItemMenuMode.chara;
6533 CDngStatusData *status = BtlMenuStatusPt;
6534 int slot = status->equipped_weapon_slot[chara];
6535 WEAPON_HAVE *row = status->chara_weapons[chara];
6536 WEAPON_HAVE *weapon = &row[slot];
6537
6538 if (weapon != NULL) {
6539 SetNowEquipWeaponDataForMsg(weapon->item_no, weapon->level);
6540 } else {
6541 SetNowEquipWeaponDataForMsg(0, 0);
6542 }
6543 } else {
6544 MenuExTextureReadFlag = MENU_EX_TEX_BUILDING;
6545 }
6546 }
6547 }
6548}
6549
6550#ifdef PAL
6554static inline int DebugGetHp(int chara) {
6555 return BtlMenuStatusPt->hp[chara];
6556}
6557
6561static inline int DebugGetMaxHp(int chara) {
6562 return BtlMenuStatusPt->max_hp[chara];
6563}
6564
6568static inline void DebugSetHp(int chara, int hp) {
6569 BtlMenuStatusPt->hp[chara] = hp;
6570}
6571
6575static inline float DebugGetWater(int chara) {
6576 return BtlMenuStatusPt->water_now[chara];
6577}
6578
6582static inline void DebugSetWater(int chara, float water) {
6583 BtlMenuStatusPt->water_now[chara] = water;
6584}
6585
6589static inline int DebugGetDefense(int chara) {
6590 return BtlMenuStatusPt->defense[chara];
6591}
6592
6596static inline void DebugSetDefense(int chara, int defense) {
6597 BtlMenuStatusPt->defense[chara] = defense;
6598}
6599#endif
6600
6604int ItemMenuMainKey() {
6605 float effect_x;
6606 float effect_y;
6607
6608 switch (MenuExTextureReadFlag) {
6609 case MENU_EX_TEX_UNREAD:
6610 if (ReadBGSync() == 0) {
6611 if (ItemMenuAlreadyReadWepIconTexFlag == 0) {
6612 ReadSyncItemMenuWepIcon();
6613 ItemMenuAlreadyReadWepIconTexFlag = 1;
6614 ItemMenuMode.state = ITEM_MENU_STATE_OPEN;
6615 }
6616
6617 MenuCharaMDSBuild2(ItemMenuMode.chara, MenuExtendReadBlock);
6618 MenuExTextureReadFlag = MENU_EX_TEX_BUILDING;
6619 BtlMDSBuildCnt = 0;
6620 }
6621
6622 break;
6623 case MENU_EX_TEX_BUILDING:
6624 BtlMDSBuildCnt++;
6625 MenuCharaFrame.Step();
6626
6627 if (ItemMenuMode.chara == 0) {
6628 MenuCharaFrame.ClothStep(0);
6629 }
6630
6631 if (BtlMDSBuildCnt > 3) {
6632 MenuExTextureReadFlag = MENU_EX_TEX_READY;
6633 }
6634
6635 break;
6636 }
6637
6638 int old_mode = ItemMenuMode.mode;
6639 int old_cursor = ItemMenuMode.board.cursor;
6640 int old_chara = ItemMenuMode.chara;
6641 int old_page = ItemMenuMode.board.page;
6642 int thrown[18];
6643 int thrown_vol[18];
6644
6645 for (int i = 0; i < 18; i++) {
6646 thrown[i] = 0;
6647 thrown_vol[i] = 0;
6648 }
6649
6650 int result = CheckItemThrow(thrown, thrown_vol);
6651 int overflowing = 0;
6652
6653 for (int i = 0; i < 3; i++) {
6654 int maximum = 0;
6655 GetNowModeMaxNum(i, &maximum);
6656
6657 if (maximum != 0) {
6658 overflowing = 1;
6659 }
6660 }
6661
6662 if (IconAutoGet.IsMoveIcon() == 0 && result == 0 && overflowing == 0 && BtlHaveItemPt->item_no < ITEM_ATTACH_START) {
6663 ItemMenuMode.overflow = false;
6664 ((CUserStatus *) BtlMenuStatusPt)->overflow_flag = false;
6665 DeleteMenuTrushMark();
6666 }
6667
6668 switch (ItemMenuMode.state) {
6669 case ITEM_MENU_STATE_LOADING:
6670 ToFromSelect(0);
6671 break;
6672 case ITEM_MENU_STATE_OPEN:
6673 result = ToFromSelect(0);
6674 ItemMenuMode.counter++;
6675
6676 if (ItemMenuMode.counter >= 0x11 && result != 0) {
6677 BtlEffectFlag = BTLEFFECT_NONE;
6678 ItemMenuMode.state = ITEM_MENU_STATE_IDLE;
6679 ItemMenuMode.counter = 0;
6680 BattleMenuFlag = BTLMENU_STATE_ITEM;
6681 }
6682
6683 break;
6684 case ITEM_MENU_STATE_CLOSE:
6685 result = ToFromSelect(1);
6686
6687 if (BtlMenuExReadFlag == 0) {
6688 BtlMenuExReadFlag = DngActItemModelBuild(0);
6689 }
6690
6691 ItemMenuMode.counter++;
6692
6693 if (ItemMenuMode.counter > 0x11 && result != 0 && BtlMenuExReadFlag != 0) {
6694 ExistItemMenu();
6695 BattleMenuFlag = BTLMENU_STATE_MAIN;
6696 }
6697
6698 break;
6699 case ITEM_MENU_STATE_EFFECT: {
6700 int motion = MenuWepLevelUp.effect.motion_state;
6701 int state = MenuWepLevelUp.effect_state;
6702
6703 if (state == WEP_EFFECT_STATE_CURE_STATUS_PLAY || state == WEP_EFFECT_STATE_CURE_FRUIT_OF_EDEN_PLAY || state == WEP_EFFECT_STATE_CURE_GOURD_PLAY || state == WEP_EFFECT_STATE_CURE_POCKET_PLAY || state == 0x1Fu || state == WEP_EFFECT_STATE_CURE_REVIVAL_POWDER_PLAY || (state == WEP_EFFECT_STATE_CURE_AILMENT_PLAY && MenuWepLevelUp.message_no > 0x190)) {
6704 if (motion == 3 && GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
6705 ItemMenuMode.state = ITEM_MENU_STATE_IDLE;
6706 MenuWepLevelUp.SetSnd(MenuWepLevelUp.snd_volume, MenuWepLevelUp.snd_from, 7);
6707 MenuWepLevelUp.Initialize();
6708 }
6709 } else if (state == WEP_EFFECT_STATE_CURE_HEAL_HP_PLAY || state == WEP_EFFECT_STATE_CURE_DRINK_PLAY || (state == WEP_EFFECT_STATE_CURE_AILMENT_PLAY && MenuWepLevelUp.message_no < 0x190) || state == WEP_EFFECT_STATE_CURE_REPAIR_PLAY) {
6710 if (motion == 3) {
6711 ItemMenuMode.state = ITEM_MENU_STATE_IDLE;
6712 MenuWepLevelUp.Initialize();
6713 }
6714 }
6715
6716 break;
6717 }
6718 case ITEM_MENU_STATE_POWERUP_CONFIRM:
6719 if (GamePad.Down(PAD_UP | PAD_DOWN) != 0) {
6720 if (ItemMenuMode.confirm != 0) {
6721 ItemMenuMode.confirm = 0;
6722 } else {
6723 ItemMenuMode.confirm = 1;
6724 }
6725
6726 ComMenuSePlay(MENU_SOUND_CURSOR);
6727 }
6728
6729 if (GamePad.Down(PAD_CROSS) != 0) {
6730 if (ItemMenuMode.confirm == 0) {
6731 WEAPON_HAVE *weapon = ItemMenuMode.target_weapon;
6732 s16 item_no = BtlHaveItemPt->item_no;
6733 int result = ItemUseFunc(BtlMenuStatusPt, item_no, ItemMenuMode.chara, ITEM_USE_ON_EQUIP_WEAPON, weapon);
6734
6735 if ((u32) (result - 1) < 2) {
6736 int sounds[2] = {1, 0x18};
6737 ComMenuSePlay(sounds[result - 1]);
6738 }
6739
6740 if (ItemMenuMode.use_target == ITEM_USE_ON_EQUIP_WEAPON) {
6741 effect_x = -16.95f;
6742 effect_y = 1.0f;
6743 }
6744
6745 if (ItemMenuMode.use_target == ITEM_USE_ON_BOARD_WEAPON) {
6746 effect_x = 4.3f + 3.2f * (float) (ItemMenuMode.board.cursor % 5);
6747 effect_y = 6.7f - 3.2f * (float) (ItemMenuMode.board.cursor / 5 - ItemMenuMode.board.top_row);
6748 }
6749
6750 CWeaponLevelUp *effect = (CWeaponLevelUp *) (MenuExCashBuffer.base + MenuExCashBuffer.used * 16);
6751 MenuWepLevelUp.CureEffect((int) effect_x, (int) effect_y, effect, BtlMenuExReadBlock, WEP_EFFECT_CURE_REPAIR);
6752 InitHaveData(BtlHaveItemPt);
6753 ItemMenuMode.state = ITEM_MENU_STATE_IDLE;
6754 ComMenuSePlay(SE_WEAPON_REPAIR);
6755 } else {
6756 ItemMenuMode.state = ITEM_MENU_STATE_IDLE;
6757 ComMenuSePlay(MENU_SOUND_REFUSE);
6758 }
6759 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
6760 ItemMenuMode.state = ITEM_MENU_STATE_IDLE;
6761 ComMenuSePlay(MENU_SOUND_REFUSE);
6762 }
6763
6764 break;
6765 case ITEM_MENU_STATE_IDLE:
6766 switch (ItemMenuMode.mode) {
6767 case ITEM_MENU_QUICK_SLOTS:
6768 case ITEM_MENU_CHARA:
6769 case ITEM_MENU_WEAPON:
6770 case ITEM_MENU_DEFENSE:
6771 ChangeMenuChara();
6772 case ITEM_MENU_TRUSH:
6773 ItemMenuModeKey();
6774 break;
6775 case ITEM_MENU_BOARD: {
6776 int done = PersonalBoardKey();
6777 int row = ItemMenuMode.board.cursor / 5 - ItemMenuMode.board.top_row;
6778
6779 if (done != 0) {
6780 if (row < 2) {
6781 ItemMenuMode.mode = ITEM_MENU_QUICK_SLOTS;
6782 ItemMenuMode.board.cursor = 2;
6783 } else {
6784 ItemMenuMode.mode = ITEM_MENU_CHARA;
6785 }
6786
6787 int page = ItemMenuMode.board.page;
6788 int count = ItemMenuMode.overflow_count[page];
6789
6790 if ((ItemMenuMode.overflow_pages & (1 << (page + 1))) && ItemMenuMode.overflow != 0) {
6791 ItemMenuMode.mode = ITEM_MENU_TRUSH;
6792 ItemMenuMode.board.cursor = row;
6793
6794 if (ItemMenuMode.board.cursor > count - 1) {
6795 ItemMenuMode.board.cursor = count - 1;
6796 }
6797
6798 if (ItemMenuMode.board.cursor <= 0) {
6799 ItemMenuMode.board.cursor = 0;
6800 }
6801 }
6802 }
6803
6804 break;
6805 }
6806 }
6807
6808 if (MenuExTextureReadFlag >= MENU_EX_TEX_READY && MenuWepLevelUp.operation_kind == WEP_EFFECT_NONE) {
6809 if (GamePad.Down(PAD_CROSS) != 0) {
6810 int cursor = ItemMenuMode.board.cursor;
6811 COM_ITEM_INFO *info = GetCommonItemInfo(BtlHaveItemPt->item_no);
6812
6813 switch (ItemMenuMode.mode) {
6814 case ITEM_MENU_QUICK_SLOTS: {
6815 int held = BtlHaveItemPt->item_no;
6816
6817 if ((held >= ITEM_ATTACH_START && held < ITEM_DUNGEON_START) || held >= ITEM_WEAPON_START) {
6818 ComMenuSePlay(MENU_SOUND_REFUSE);
6819 } else if (IconAutoGet.IsMoveIcon() != 0) {
6820 ComMenuSePlay(MENU_SOUND_REFUSE);
6821 } else {
6822 s16 *slot_item = &MenuItemPackPt->quick_item_slot[cursor];
6823 s16 *slot_qty = &MenuItemPackPt->quick_item_qty[cursor];
6824 ITEM_DATA *slot_data = NULL;
6825
6826 if (*slot_item >= ITEM_DUNGEON_START) {
6827 slot_data = GetItemData(*slot_item);
6828 }
6829
6830 int held_kind = 0;
6831 ITEM_DATA *held_data = NULL;
6832
6833 if (BtlHaveItemPt->item_no >= ITEM_DUNGEON_START) {
6834 held_data = GetItemData(BtlHaveItemPt->item_no);
6835 held_kind = held_data->stack_kind;
6836 }
6837
6838 int stack = 0;
6839 int ok = 0;
6840 int take = 0;
6841
6842 switch (held_kind) {
6843 case ITEM_STACK_NEVER:
6844 break;
6845 case ITEM_STACK_SINGLE:
6846 if (slot_data == NULL) {
6847 ok = 1;
6848 } else {
6849 switch (slot_data->stack_kind) {
6850 case ITEM_STACK_SINGLE:
6851 ok = 1;
6852 break;
6853 case ITEM_STACK_MULTI:
6854 ok = 1;
6855
6856 if (*slot_qty >= 2) {
6857 ok = 0;
6858 }
6859
6860 break;
6861 }
6862 }
6863
6864 break;
6865 case ITEM_STACK_MULTI:
6866 if (slot_data == NULL) {
6867 ok = 1;
6868 } else {
6869 ok = 1;
6870
6871 if (slot_data->stack_kind == ITEM_STACK_MULTI) {
6872 if (*slot_item == BtlHaveItemPt->item_no) {
6873 if (*slot_qty < 9) {
6874 stack = 1;
6875 } else {
6876 ok = 0;
6877 }
6878 } else if (held_data == NULL) {
6879 take = 1;
6880 } else if (*slot_qty >= 2) {
6881 ok = 0;
6882 }
6883 }
6884 }
6885
6886 break;
6887 }
6888
6889 if (ok == 0) {
6890 ComMenuSePlay(MENU_SOUND_REFUSE);
6891 } else {
6892 if (stack != 0) {
6893 if (*slot_qty == 0) {
6894 *slot_qty = 1;
6895 } else {
6896 (*slot_qty)++;
6897 }
6898
6899 InitHaveData(BtlHaveItemPt);
6900 } else if (take != 0) {
6901 BtlHaveItemPt->item_no = *slot_item;
6902 BtlHaveItemPt->slot_state = ITEM_MENU_QUICK_SLOTS;
6903 BtlHaveItemPt->from_slot = cursor;
6904 (*slot_qty)--;
6905
6906 if (*slot_qty <= 0) {
6907 *slot_item = -1;
6908 *slot_qty = 0;
6909 }
6910 } else if (ok != 0) {
6911 MenuDataSwap(slot_item, &BtlHaveItemPt->item_no);
6912 CUserStatus *status = (CUserStatus *) BtlMenuStatusPt;
6913 int vol = status->active_item_vol[cursor];
6914 status->active_item_vol[cursor] = BtlHaveItemPt->volume;
6915 BtlHaveItemPt->volume = vol;
6916
6917 if (*slot_item >= ITEM_DUNGEON_START) {
6918 *slot_qty = 1;
6919 } else {
6920 *slot_qty = 0;
6921 }
6922
6923 if (BtlHaveItemPt->item_no >= ITEM_DUNGEON_START) {
6924 BtlHaveItemPt->slot_state = ITEM_MENU_QUICK_SLOTS;
6925 BtlHaveItemPt->from_slot = cursor;
6926 }
6927 }
6928
6929 ComMenuSePlay(MENU_SOUND_CONFIRM);
6930 }
6931 }
6932
6933 break;
6934 }
6935 case ITEM_MENU_CHARA:
6936 if (info == NULL) {
6937 ComMenuSePlay(MENU_SOUND_REFUSE);
6938 } else if (info->kind != ITEMKIND_ITEM) {
6939 ComMenuSePlay(MENU_SOUND_REFUSE);
6940 } else {
6941 int chara = ItemMenuMode.chara;
6942 int result = ItemUseFunc(BtlMenuStatusPt, BtlHaveItemPt->item_no, chara, ITEM_USE_ON_CHARA, NULL);
6943 int sounds[4] = {2, 1, 0x18, -1};
6944 int sound;
6945
6946 if (result < 4) {
6947 sound = sounds[result];
6948 } else {
6949 sound = 2;
6950 }
6951
6952 if (sound == 2) {
6953 ComMenuSePlay(MENU_SOUND_REFUSE);
6954 } else {
6955 ITEM_DATA *data = GetItemData(BtlHaveItemPt->item_no);
6956 int effect = WEP_EFFECT_NONE;
6957
6958 if (sound > 0) {
6959 u32 use = data->use_flags;
6960
6961 if ((use & 0x80) && (data->kind_flags & 4)) {
6962 effect = WEP_EFFECT_CURE_DRINK;
6963 effect_x = -5.0f;
6964 effect_y = -3.0f;
6965 }
6966
6967 if ((use & 0x40) && (data->kind_flags & 4)) {
6968 effect = WEP_EFFECT_CURE_HEAL_HP;
6969 effect_x = -5.5f;
6970 effect_y = -6.0f;
6971 ComMenuSePlay(SE_EFFECT_CHIME);
6972 }
6973
6974 if ((data->use_flags & 0x20) && (data->kind_flags & 0x20)) {
6975 effect = WEP_EFFECT_CURE_STATUS;
6976 effect_x = -5.5f;
6977 effect_y = -6.0f;
6978 int volume = GetMenuItemUseVolume();
6979 MenuWepLevelUp.message_no = ItemMenuMode.chara;
6980 MenuWepLevelUp.message_value = volume;
6981 }
6982
6983 if ((data->kind_flags & 1) && ((data->use_flags & 0x4000) || (data->use_flags & 0x8000) || (data->use_flags & 0x10000) || (data->use_flags & 0x20000) || (data->use_flags & 0x3C000))) {
6984 int message;
6985
6986 switch (BtlHaveItemPt->item_no) {
6987 case ITEM_ANTIDOTE_DRINK:
6988 message = 0x1A2;
6989 break;
6990 case ITEM_HOLY_WATER:
6991 message = 0x1A3;
6992 break;
6993 case ITEM_SOAP:
6994 message = 0x1A4;
6995 break;
6996 case ITEM_MIGHTY_HEALING:
6997 message = 0x1A5;
6998 break;
6999 default:
7000 message = -1;
7001 break;
7002 }
7003
7004 MenuWepLevelUp.message_no = message;
7005 MenuWepLevelUp.message_value = 0;
7006 effect = WEP_EFFECT_CURE_AILMENT;
7007 effect_x = -6.0f;
7008 effect_y = -2.0f;
7009 ComMenuSePlay(SE_EFFECT_CHIME);
7010 }
7011
7012 if ((data->kind_flags & 1) && (data->use_flags & 0x1000)) {
7013 effect = WEP_EFFECT_CURE_AILMENT;
7014
7015 if (BtlMenuMode == BATTLE_MENU_MODE_DUNGEON) {
7016 ComMenuSePlay(SE_POWER_UP);
7017 }
7018
7019 effect_x = -6.0f;
7020 effect_y = -2.0f;
7021 }
7022
7023 if (BtlHaveItemPt->item_no == ITEM_POCKET) {
7024 effect = WEP_EFFECT_CURE_POCKET;
7025 effect_x = 19.03f;
7026 effect_y = 9.1f;
7027 int volume = GetMenuItemUseVolume();
7028 MenuWepLevelUp.message_no = ItemMenuMode.chara;
7029 MenuWepLevelUp.message_value = volume;
7030 }
7031
7032 if (BtlHaveItemPt->item_no == ITEM_FRUIT_OF_EDEN) {
7033 effect = WEP_EFFECT_CURE_FRUIT_OF_EDEN;
7034 effect_x = -5.5f;
7035 effect_y = -6.0f;
7036 int volume = GetMenuItemUseVolume();
7037 MenuWepLevelUp.message_no = ItemMenuMode.chara;
7038 MenuWepLevelUp.message_value = volume;
7039 }
7040
7041 if (BtlHaveItemPt->item_no == ITEM_GOURD) {
7042 effect = WEP_EFFECT_CURE_GOURD;
7043 effect_x = -5.5f;
7044 effect_y = -6.0f;
7045 int volume = GetMenuItemUseVolume();
7046 MenuWepLevelUp.message_no = ItemMenuMode.chara;
7047 MenuWepLevelUp.message_value = volume;
7048 }
7049
7050 if (BtlHaveItemPt->item_no == ITEM_REVIVAL_POWDER) {
7051 effect = WEP_EFFECT_CURE_REVIVAL_POWDER;
7052 effect_x = -5.5f;
7053 effect_y = -2.0f;
7054 int volume = GetMenuItemUseVolume();
7055 MenuWepLevelUp.message_no = ItemMenuMode.chara;
7056 MenuWepLevelUp.message_value = volume;
7057 }
7058
7059 if (effect > 0) {
7060 ItemMenuMode.state = ITEM_MENU_STATE_EFFECT;
7061 CWeaponLevelUp *buffer = (CWeaponLevelUp *) (MenuExCashBuffer.base + MenuExCashBuffer.used * 16);
7062 MenuWepLevelUp.CureEffect((int) effect_x, (int) effect_y, buffer, BtlMenuExReadBlock, effect);
7063 }
7064
7065 InitHaveData(BtlHaveItemPt);
7066 }
7067 }
7068 }
7069
7070 break;
7071 case ITEM_MENU_WEAPON: {
7072 int chara = ItemMenuMode.chara;
7073 int slot = BtlMenuStatusPt->equipped_weapon_slot[chara];
7074 WEAPON_HAVE *row = BtlMenuStatusPt->chara_weapons[chara];
7075 ItemMenuMode.target_weapon = &row[slot];
7076 int is_default = 0;
7077 WEAPON_HAVE *weapon = ItemMenuMode.target_weapon;
7078 int before = weapon->item_no;
7079
7080 if (before == GetDefaultWeaponNo(ItemMenuMode.chara)) {
7081 is_default = 1;
7082 }
7083
7084 int held = BtlHaveItemPt->item_no;
7085
7086 if (held == ITEM_POWERUP_POWDER && is_default == 0) {
7087 WEAPON_HAVE *target = ItemMenuMode.target_weapon;
7088
7089 if (target->experience >= GetWeaponMaxExp(weapon)) {
7090 ComMenuSePlay(MENU_SOUND_REFUSE);
7091 } else if (target->level >= 99) {
7092 ComMenuSePlay(MENU_SOUND_REFUSE);
7093 } else if (target->item_no == ITEM_WEAPON_SERPENT_SWORD && GetMenuHebikiriFlag() == 0) {
7094 ComMenuSePlay(MENU_SOUND_REFUSE);
7095 } else {
7096 ItemMenuMode.state = ITEM_MENU_STATE_POWERUP_CONFIRM;
7097 ItemMenuMode.use_target = ITEM_USE_ON_EQUIP_WEAPON;
7098 ItemMenuMode.confirm = 1;
7099 ComMenuSePlay(MENU_SOUND_CONFIRM);
7100 }
7101 } else if (held != ITEM_POWERUP_POWDER && held != ITEM_REPAIR_POWDER) {
7102 ComMenuSePlay(MENU_SOUND_REFUSE);
7103 } else {
7104 int result = ItemUseFunc(BtlMenuStatusPt, held, ItemMenuMode.chara, ITEM_USE_ON_BOARD_WEAPON, weapon);
7105 int after = ItemMenuMode.target_weapon->item_no;
7106
7107 if ((u32) (result - 1) < 2) {
7108 s16 sounds[2] = {1, 0x18};
7109 ComMenuSePlay(sounds[result - 1]);
7110 MenuWepLevelUp.CureEffect(-0x10, 1, (CWeaponLevelUp *) (MenuExCashBuffer.base + MenuExCashBuffer.used * 16), BtlMenuExReadBlock, WEP_EFFECT_CURE_REPAIR);
7111
7112 if (BtlMenuMode == BATTLE_MENU_MODE_DUNGEON) {
7113 if (before != after) {
7114 int who = ((CUserStatus *) BtlMenuStatusPt)->cur_chara;
7115
7116 if (ItemMenuMode.chara == who) {
7117 EquipWeaponFrame(&DefaultWeapon, ItemMenuMode.chara, CharaMainHandViewFlag);
7118
7119 if (((CUserStatus *) BtlMenuStatusPt)->cur_chara == CHARA_OSMOND) {
7120 NowMainEffect = &CharaMainEffectCrash;
7121 BtActStatus.gun_type = 0;
7122 }
7123 }
7124 }
7125
7126 MenuWeaponSpSet(&MainWeapon, ItemMenuMode.target_weapon);
7127 }
7128
7129 SetNowEquipWeaponDataForMsg(ItemMenuMode.target_weapon->item_no, ItemMenuMode.target_weapon->level);
7130 InitHaveData(BtlHaveItemPt);
7131 } else {
7132 ComMenuSePlay(MENU_SOUND_REFUSE);
7133 }
7134 }
7135
7136 break;
7137 }
7138 case ITEM_MENU_DEFENSE:
7139 ComMenuSePlay(MENU_SOUND_REFUSE);
7140 break;
7141 case ITEM_MENU_BOARD: {
7142 s16 held = BtlHaveItemPt->item_no;
7143 PERSONAL_BOARD *board = &ItemMenuMode.board;
7144
7145 if (board->cursor_area == PERSONAL_BOARD_AREA_TRASH) {
7146 if (held < ITEM_ATTACH_START) {
7147 ComMenuSePlay(MENU_SOUND_REFUSE);
7148 } else if (IsEnableTrushThrow(held) != 0) {
7149 board->trash_anim = 1;
7150 board->trash_frame = 0;
7151 InitHaveData(BtlHaveItemPt);
7152 ComMenuSePlay(MENU_SOUND_CONFIRM);
7153 } else {
7154 ComMenuSePlay(MENU_SOUND_REFUSE);
7155 }
7156 } else {
7157 int before = -1;
7158 int item = held;
7159
7160 if (ItemMenuMode.board.page == BOARD_PAGE_WEAPON) {
7161 int chara = ItemMenuMode.board.cursor / 10;
7162 int slot = ItemMenuMode.board.cursor % 10;
7163 CDngStatusData *status = BtlMenuStatusPt;
7164 WEAPON_HAVE *row = status->chara_weapons[chara];
7165 ItemMenuMode.target_weapon = &row[slot];
7166 before = ItemMenuMode.target_weapon->item_no;
7167 }
7168
7169 int result = PersonalBoardItemGetorSwap(ItemMenuMode.board.cursor);
7170
7171 if (result == 0) {
7172 ComMenuSePlay(MENU_SOUND_REFUSE);
7173 } else if (result == 1) {
7174 if (BtlHaveItemPt->item_no >= ITEM_ATTACH_START) {
7175 BtlHaveItemPt->slot_state = ITEM_MENU_BOARD;
7176 } else {
7177 InitHaveData(BtlHaveItemPt);
7178 InitHaveWep(&ItemMenuMode.board.weapon);
7179 InitHaveAttach(&ItemMenuMode.board.held_attach);
7180 }
7181
7182 ComMenuSePlay(MENU_SOUND_CONFIRM);
7183 } else if (result == 2) {
7184 float x = 4.3f + 3.2f * (float) (ItemMenuMode.board.cursor % 5);
7185 float y = 6.7f - 3.2f * (float) (ItemMenuMode.board.cursor / 5 - ItemMenuMode.board.top_row);
7186
7187 if (item == ITEM_REPAIR_POWDER) {
7188 CWeaponLevelUp *effect = (CWeaponLevelUp *) (MenuExCashBuffer.base + MenuExCashBuffer.used * 16);
7189 MenuWepLevelUp.CureEffect((int) x, (int) y, effect, BtlMenuExReadBlock, WEP_EFFECT_CURE_REPAIR);
7190 }
7191
7192 if (ItemMenuMode.board.page == BOARD_PAGE_WEAPON) {
7193 if (item == ITEM_REPAIR_POWDER) {
7194 int after = ItemMenuMode.target_weapon->item_no;
7195
7196 if (BtlMenuMode == BATTLE_MENU_MODE_DUNGEON) {
7197 if (after != before) {
7198 EquipWeaponFrame(&DefaultWeapon, ItemMenuMode.chara, CharaMainHandViewFlag);
7199 }
7200
7201 MenuWeaponSpSet(&MainWeapon, ItemMenuMode.target_weapon);
7202 }
7203
7204 ComMenuSePlay(SE_WEAPON_REPAIR);
7205 }
7206
7207 if (item == ITEM_POWERUP_POWDER && before != GetDefaultWeaponNo(ItemMenuMode.board.cursor / 10)) {
7208 ItemMenuMode.state = ITEM_MENU_STATE_POWERUP_CONFIRM;
7209 ItemMenuMode.use_target = ITEM_USE_ON_BOARD_WEAPON;
7210 ItemMenuMode.confirm = 1;
7211 ComMenuSePlay(MENU_SOUND_CONFIRM);
7212 }
7213 }
7214 } else if (result == 1) {
7215 ComMenuSePlay(MENU_SOUND_CONFIRM);
7216 } else {
7217 ComMenuSePlay(MENU_SOUND_REFUSE);
7218 }
7219 }
7220
7221 break;
7222 }
7223 case ITEM_MENU_TRUSH:
7224 if (ItemTrushKey(thrown, thrown_vol, ItemMenuMode.board.cursor) != 0) {
7225 BtlHaveItemPt->slot_state = ITEM_MENU_TRUSH;
7226 BtlHaveItemPt->from_slot = ItemMenuMode.board.cursor;
7227 ComMenuSePlay(MENU_SOUND_CONFIRM);
7228 } else {
7229 ComMenuSePlay(MENU_SOUND_REFUSE);
7230 }
7231
7232 break;
7233 }
7234 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
7235 ComMenuSePlay(MENU_SOUND_REFUSE);
7236
7237 if (BtlHaveItemPt->item_no < ITEM_ATTACH_START && IconAutoGet.IsMoveIcon() == 0 && ItemMenuMode.overflow == 0) {
7238 BattleMenuFlag = BTLMENU_STATE_ITEM_CLOSE;
7239 u_long128 *buffer = BtlMenuReadBuf;
7240
7241 switch (BtlMenuMode) {
7242 case BATTLE_MENU_MODE_DUNGEON:
7243 BtlMenuExReadFlag = DngActItemModelReadStart(buffer);
7244 break;
7245 }
7246
7247 ExitItemSelect();
7248 ItemMenuMode.state = ITEM_MENU_STATE_CLOSE;
7249 ItemMenuMode.counter = 0;
7250 } else if (IconAutoGet.IsMoveIcon() != 0) {
7251 ComMenuSePlay(MENU_SOUND_REFUSE);
7252 break;
7253 } else {
7254 s16 *slot_item;
7255 s16 *slot_qty;
7256 s16 vol;
7257 s16 item_no;
7258 s16 held = BtlHaveItemPt->item_no;
7259
7260 switch (BtlHaveItemPt->slot_state) {
7261 case ITEM_MENU_TRUSH:
7262 switch (WhatIsKindofItem(held)) {
7263 case BOARD_PAGE_ITEM:
7264 MenuDataSwap(&BtlHaveItemPt->item_no, &MenuItemPackPt->item[MenuItemPackPt->num + BtlHaveItemPt->from_slot]);
7265 MenuDataSwap(&BtlHaveItemPt->volume, &MenuItemPackPt->item_vol[MenuItemPackPt->num + BtlHaveItemPt->from_slot]);
7266 break;
7267 case BOARD_PAGE_WEAPON: {
7268 int who = WhoIsWeaponEquip(held);
7269 CDngStatusData *status = BtlMenuStatusPt;
7270 WEAPON_HAVE *weapons = status->chara_weapons[who];
7271 WEAPON_HAVE *weapon = &weapons[10];
7272 item_no = weapons[10].item_no;
7273 MenuDataSwap(weapon, &ItemMenuMode.board.weapon);
7274 BtlHaveItemPt->item_no = item_no;
7275 weapon->item_no = held;
7276
7277 if (BtlHaveItemPt->item_no < ITEM_WEAPON_START) {
7278 InitHaveData(BtlHaveItemPt);
7279 InitHaveWep(&ItemMenuMode.board.weapon);
7280 }
7281
7282 break;
7283 }
7284 case BOARD_PAGE_ATTACH: {
7285 ATTACH_LIST *attach = &((ATTACH_LIST *) BtlMenuStatusPt->consumable_items)[BtlHaveItemPt->from_slot];
7286 item_no = attach->item_no;
7287 MenuDataSwap(attach, &ItemMenuMode.board.held_attach);
7288 BtlHaveItemPt->item_no = item_no;
7289 attach->item_no = held;
7290 break;
7291 }
7292 }
7293
7294 break;
7295 case ITEM_MENU_BOARD:
7296 PersonalBoardItemCancel();
7297 break;
7298 case ITEM_MENU_QUICK_SLOTS: {
7299 int slot = BtlHaveItemPt->from_slot;
7300 slot_item = &MenuItemPackPt->quick_item_slot[slot];
7301 slot_qty = &MenuItemPackPt->quick_item_qty[slot];
7302 CUserStatus *status = (CUserStatus *) BtlMenuStatusPt;
7303 vol = status->active_item_vol[slot];
7304
7305 if (*slot_qty < 2 && *slot_item != held && held >= ITEM_DUNGEON_START) {
7306 MenuDataSwap(slot_item, &BtlHaveItemPt->item_no);
7307 int held_vol = BtlHaveItemPt->volume;
7308
7309 if (held_vol <= 0) {
7310 held_vol = 0;
7311 }
7312
7313 status = (CUserStatus *) BtlMenuStatusPt;
7314 status->active_item_vol[slot] = held_vol;
7315 BtlHaveItemPt->volume = vol;
7316 *slot_qty = 1;
7317 } else if (*slot_item == held && held >= ITEM_DUNGEON_START && *slot_qty < 9) {
7318 switch (GetItemData(held)->stack_kind) {
7319 case ITEM_STACK_SINGLE: {
7320 MenuDataSwap(slot_item, &BtlHaveItemPt->item_no);
7321 int held_vol = BtlHaveItemPt->volume;
7322
7323 if (held_vol <= 0) {
7324 held_vol = 0;
7325 }
7326
7327 status = (CUserStatus *) BtlMenuStatusPt;
7328 status->active_item_vol[slot] = held_vol;
7329 BtlHaveItemPt->volume = vol;
7330 *slot_qty = 1;
7331 break;
7332 }
7333 case ITEM_STACK_MULTI:
7334 (*slot_qty)++;
7335 InitHaveData(BtlHaveItemPt);
7336 break;
7337 }
7338
7339 if (BtlHaveItemPt->item_no < ITEM_ATTACH_START) {
7340 InitHaveData(BtlHaveItemPt);
7341 }
7342 }
7343
7344 break;
7345 }
7346 }
7347 }
7348 } else if (GamePad.Down(PAD_SQUARE) != 0) {
7349 switch (ItemMenuMode.mode) {
7350 case ITEM_MENU_QUICK_SLOTS: {
7351 int cursor = ItemMenuMode.board.cursor;
7352 ITEM_PACK *pack = MenuItemPackPt;
7353 s16 *items = pack->item;
7354 s16 *vols = pack->item_vol;
7355 s16 *slot_item = &pack->quick_item_slot[cursor];
7356 s16 *slot_qty = &pack->quick_item_qty[cursor];
7357 int i;
7358 CUserStatus *status = (CUserStatus *) BtlMenuStatusPt;
7359 s16 vol = status->active_item_vol[cursor];
7360
7361 if (*slot_item > 0) {
7362 for (i = 0; 0 < *slot_qty || i < MenuItemPackPt->num; i++) {
7363 if (items[i] < 0) {
7364 items[i] = *slot_item;
7365 vols[i] = vol;
7366 CUserStatus *holder = (CUserStatus *) BtlMenuStatusPt;
7367 holder->active_item_vol[cursor] = 0;
7368 (*slot_qty)--;
7369
7370 if (*slot_qty <= 0) {
7371 *slot_item = -1;
7372 break;
7373 }
7374 }
7375 }
7376 }
7377
7378 if (((CUserStatus *) BtlMenuStatusPt)->overflow_flag != 0) {
7379 DeleteMenuTrushMark();
7380 SetMenuTrushMark((ITEM_PACK *) ((CUserStatus *) BtlMenuStatusPt)->active_item);
7381 }
7382
7383 ComMenuSePlay(MENU_SOUND_REFUSE);
7384 break;
7385 }
7386 case ITEM_MENU_BOARD:
7387 case ITEM_MENU_DEFENSE:
7388 case ITEM_MENU_CHARA:
7389 switch (ItemMenuMode.board.page) {
7390 case BOARD_PAGE_ITEM:
7391 SeitonItemBoard(MenuItemPackPt);
7392
7393 if (((CUserStatus *) BtlMenuStatusPt)->overflow_flag != 0) {
7394 SetMenuTrushMark((ITEM_PACK *) ((CUserStatus *) BtlMenuStatusPt)->active_item);
7395 }
7396
7397 ComMenuSePlay(MENU_SOUND_CONFIRM);
7398 break;
7399 case BOARD_PAGE_ATTACH:
7400 SeitonAttachBoard((ATTACH_LIST *) BtlMenuStatusPt->consumable_items);
7401 ComMenuSePlay(MENU_SOUND_CONFIRM);
7402 break;
7403 }
7404
7405 break;
7406 }
7407 } else if (GamePad.Down(PAD_TRIANGLE) != 0) {
7408 int cursor = ItemMenuMode.board.cursor;
7409 s16 *items = MenuItemPackPt->item;
7410
7411 switch (ItemMenuMode.mode) {
7412 case ITEM_MENU_QUICK_SLOTS: {
7413 s16 *slot_item = &MenuItemPackPt->quick_item_slot[cursor];
7414 s16 *slot_qty = &MenuItemPackPt->quick_item_qty[cursor];
7415
7416 if (*slot_item < ITEM_DUNGEON_START) {
7417 ComMenuSePlay(MENU_SOUND_REFUSE);
7418 break;
7419 }
7420
7421 ITEM_DATA *data = GetItemData(*slot_item);
7422
7423 if (data->stack_kind == ITEM_STACK_NEVER) {
7424 ComMenuSePlay(MENU_SOUND_REFUSE);
7425 break;
7426 }
7427
7428 int moving = IconAutoGet.IsSameItem(*slot_item);
7429
7430 if (moving > 0) {
7431 ComMenuSePlay(MENU_SOUND_CONFIRM);
7432 } else if (data->stack_kind == ITEM_STACK_SINGLE) {
7433 ComMenuSePlay(MENU_SOUND_REFUSE);
7434 } else {
7435 int space = IconAutoGet.GetSpace();
7436 int qty = *slot_qty;
7437 int total = qty + moving;
7438
7439 if (total >= 9 || space < 0) {
7440 ComMenuSePlay(MENU_SOUND_REFUSE);
7441 } else {
7442 s16 held = BtlHaveItemPt->item_no;
7443
7444 if (held >= ITEM_DUNGEON_START && held == *slot_item && total == 8) {
7445 *slot_qty = qty + 1;
7446 BtlHaveItemPt->item_no = 0;
7447 ComMenuSePlay(MENU_SOUND_CONFIRM);
7448 } else {
7449 int found = 0;
7450
7451 for (int i = 0; i < MenuItemPackPt->num; i++) {
7452 int want = *slot_item;
7453
7454 if ((want < ITEM_DUNGEON_START || want == items[i]) && (want >= ITEM_DUNGEON_START || held == items[i])) {
7455 int y = (int) (ItemMenuMode.board.y + (float) (i / 5 * 0x28));
7456
7457 if (y >= 0x78 && y < 0x119) {
7458 int x = i % 5 * 0x28 + 0x168;
7459 int vol = MenuItemPackPt->item_vol[cursor];
7460
7461 if (want < 0) {
7462 want = held;
7463 }
7464
7465 IconAutoGet.IconMoveTarSet(space, cursor, want, vol, (float) x, (float) y);
7466 } else {
7467 if (want <= 0) {
7468 *slot_item = held;
7469 }
7470
7471 (*slot_qty)++;
7472 }
7473
7474 items[i] = -1;
7475 found = 1;
7476 break;
7477 }
7478 }
7479
7480 if (found == 0) {
7481 if (BtlHaveItemPt->item_no > 0 && BtlHaveItemPt->item_no == *slot_item) {
7482 (*slot_qty)++;
7483 BtlHaveItemPt->item_no = 0;
7484 found = 1;
7485 }
7486 }
7487
7488 if (found != 0) {
7489 ComMenuSePlay(MENU_SOUND_CONFIRM);
7490 } else {
7491 ComMenuSePlay(MENU_SOUND_REFUSE);
7492 }
7493 }
7494 }
7495 }
7496
7497 break;
7498 }
7499 case ITEM_MENU_BOARD:
7500 if (ItemMenuMode.board.cursor_area == PERSONAL_BOARD_AREA_TRASH) {
7501 ComMenuSePlay(MENU_SOUND_REFUSE);
7502 } else if (ItemMenuMode.board.page == BOARD_PAGE_WEAPON || ItemMenuMode.board.page == BOARD_PAGE_ATTACH) {
7503 ComMenuSePlay(MENU_SOUND_REFUSE);
7504 } else {
7505 int space = IconAutoGet.GetSpace();
7506
7507 if (space < 0) {
7508 break;
7509 }
7510
7511 if (IconAutoGet.IsMoveIcon() != 0) {
7512 ComMenuSePlay(MENU_SOUND_REFUSE);
7513 break;
7514 }
7515
7516 int pos = ItemMenuMode.board.cursor;
7517 int item_no = SearchBoardNowPosItemExist(ItemMenuMode.board.page, pos);
7518
7519 if (item_no < ITEM_DUNGEON_START) {
7520 ComMenuSePlay(MENU_SOUND_REFUSE);
7521 break;
7522 }
7523
7524 ITEM_DATA *data = GetItemData(item_no);
7525
7526 if (data->stack_kind == ITEM_STACK_NEVER) {
7527 ComMenuSePlay(MENU_SOUND_REFUSE);
7528 break;
7529 }
7530
7531 int vol = MenuItemPackPt->item_vol[ItemMenuMode.board.cursor];
7532 int same = 0;
7533 int slot;
7534 int empty = -1;
7535
7536 for (slot = 0; slot < 3; slot++) {
7537 s16 slot_item = MenuItemPackPt->quick_item_slot[slot];
7538 int moving = IconAutoGet.GetMoveIconGole(slot, slot_item);
7539
7540 if ((data->stack_kind == ITEM_STACK_MULTI && slot_item == item_no && MenuItemPackPt->quick_item_qty[slot] + moving < 9) || (data->stack_kind == ITEM_STACK_SINGLE && slot_item < ITEM_DUNGEON_START)) {
7541 same = 1;
7542 break;
7543 }
7544
7545 if (slot_item < ITEM_DUNGEON_START) {
7546 empty = slot;
7547 break;
7548 }
7549 }
7550
7551 if (same != 0 || empty >= 0) {
7552 int target = 0;
7553
7554 if (same != 0) {
7555 target = slot;
7556
7557 if (GetItemData(item_no)->stack_kind == ITEM_STACK_SINGLE && MenuItemPackPt->quick_item_qty[slot] == 1) {
7558 ComMenuSePlay(MENU_SOUND_REFUSE);
7559 break;
7560 }
7561 } else if (empty >= 0) {
7562 target = empty;
7563 }
7564
7565 int y = (int) (ItemMenuMode.board.y + (float) (pos / 5 * 0x28));
7566
7567 if (y >= 0x78 && y < 0x119) {
7568 IconAutoGet.IconMoveTarSet(space, target, item_no, vol, (float) (pos % 5 * 0x28 + 0x176), (float) y);
7569 } else {
7570 MenuItemPackPt->quick_item_qty[target]++;
7571 }
7572
7573 items[pos] = -1;
7574 ComMenuSePlay(MENU_SOUND_CONFIRM);
7575 } else {
7576 ComMenuSePlay(MENU_SOUND_REFUSE);
7577 }
7578 }
7579
7580 break;
7581 }
7582 }
7583 }
7584
7585#ifdef PAL
7586 // Debug builds edit the selected member's life, water and defense and the party's money, and open the
7587 // debug item list.
7588 if (DebugMode) {
7589 switch (ItemMenuMode.mode) {
7590 case ITEM_MENU_CHARA: {
7591 int hp = DebugGetHp(ItemMenuMode.chara);
7592 int max_hp = DebugGetMaxHp(ItemMenuMode.chara);
7593
7594 if (GamePad.On2(PAD_CROSS) && hp < max_hp) {
7595 hp++;
7596 }
7597
7598 if (GamePad.On2(PAD_CIRCLE) && hp > 1) {
7599 hp--;
7600 }
7601
7602 if (GamePad.On2(PAD_SQUARE)) {
7603 hp = 0;
7604 }
7605
7606 DebugSetHp(ItemMenuMode.chara, hp);
7607
7608 if (GamePad.On2(PAD_TRIANGLE)) {
7609 float water = DebugGetWater(ItemMenuMode.chara);
7610
7611 if (water > 0.0f) {
7612 water -= 1.0f;
7613 }
7614
7615 DebugSetWater(ItemMenuMode.chara, water);
7616 }
7617
7618 break;
7619 }
7620 case ITEM_MENU_DEFENSE: {
7621 int defense = DebugGetDefense(ItemMenuMode.chara);
7622
7623 if (GamePad.On2(PAD_CROSS) && defense < 999) {
7624 defense++;
7625 }
7626
7627 if (GamePad.On2(PAD_CIRCLE) && 0 < defense) {
7628 defense--;
7629 }
7630
7631 DebugSetDefense(ItemMenuMode.chara, defense);
7632 break;
7633 }
7634 }
7635
7636 if (GamePad.On2(PAD_SQUARE)) {
7637 switch (ItemMenuMode.mode) {
7638 case ITEM_MENU_CHARA: {
7639 float water = DebugGetWater(ItemMenuMode.chara) - 1.0f;
7640
7641 if (water < 0.0f) {
7642 water = 0.0f;
7643 }
7644
7645 DebugSetWater(ItemMenuMode.chara, water);
7646 break;
7647 }
7648 }
7649 }
7650
7651 if (GamePad.On2(PAD_TRIANGLE)) {
7652 switch (ItemMenuMode.mode) {
7653 case ITEM_MENU_CHARA:
7654 break;
7655 case ITEM_MENU_DEFENSE: {
7656 CDngStatusData *status = BtlMenuStatusPt;
7657 int money = status->money + 1000;
7658
7659 if (money >= 0xFFFF) {
7660 status->money = 0xFFFF;
7661 } else {
7662 status->money = money;
7663 }
7664
7665 break;
7666 }
7667 }
7668 }
7669
7670 if (GamePad.Down(PAD_SELECT)) {
7671 ItemMenuMode.state = ITEM_MENU_STATE_DEBUG_ITEMS;
7672 InitDebugItemGet();
7673 }
7674 }
7675
7676#endif
7677 break;
7678 case ITEM_MENU_STATE_DEBUG_ITEMS:
7679 if (DebugItemGetKey() == -1) {
7680 ItemMenuMode.state = ITEM_MENU_STATE_IDLE;
7681 }
7682
7683 break;
7684 }
7685
7686 if (old_mode != ItemMenuMode.mode || old_cursor != ItemMenuMode.board.cursor || old_chara != ItemMenuMode.chara || old_page != ItemMenuMode.board.page) {
7687 ComMenuSePlay(MENU_SOUND_CURSOR);
7688 }
7689
7690 if (GamePad.Down(PAD_L2 | PAD_R2 | PAD_L1 | PAD_R1) != 0 && ItemMenuMode.mode == ITEM_MENU_CHARA && old_chara == ItemMenuMode.chara) {
7691 ComMenuSePlay(MENU_SOUND_REFUSE);
7692 }
7693
7694 PERSONAL_BOARD *board = &ItemMenuMode.board;
7695 int cursor = board->cursor;
7696 int chara_mes = -1;
7697 int value = -1;
7698 int name_mes = -1;
7699
7700 if (GetCommonItemInfo(BtlHaveItemPt->item_no) != NULL) {
7701 chara_mes = -1;
7702 }
7703
7704 s16 held = BtlHaveItemPt->item_no;
7705
7706 if (held >= ITEM_ATTACH_START) {
7707 if (held == ITEM_ATTACH_SYNTHESIS_SPHERE) {
7708 name_mes = GetWeaponMsgNo2(ItemMenuMode.board.held_attach.sphere_weapon_no);
7709 }
7710
7711 value = GetAttachVolumeForMsg(&ItemMenuMode.board.held_attach);
7712 }
7713
7714 int messages[7] = {-1, 0xC1, 0xBF, 0xBD, -1, -1, -1};
7715 int message = messages[ItemMenuMode.mode];
7716
7717 switch (ItemMenuMode.mode) {
7718 case ITEM_MENU_QUICK_SLOTS: {
7719 s16 *slot = &MenuItemPackPt->quick_item_slot[cursor];
7720
7721 if (*slot >= ITEM_DUNGEON_START) {
7722 message = *slot + 0x1F4;
7723 }
7724
7725 break;
7726 }
7727 case ITEM_MENU_CHARA:
7728 chara_mes = ItemMenuMode.chara;
7729 break;
7730 case ITEM_MENU_WEAPON:
7731 GetNowEquipWeaponDataForMsg(name_mes, value);
7732 break;
7733 case ITEM_MENU_DEFENSE:
7734 break;
7735 case ITEM_MENU_TRUSH:
7736 switch (ItemMenuMode.board.page) {
7737 case BOARD_PAGE_ITEM: {
7738 s16 item_no = MenuItemPackPt->item[MenuItemPackPt->num + ItemMenuMode.board.cursor];
7739
7740 if (item_no >= ITEM_DUNGEON_START) {
7741 message = item_no + 0x1F4;
7742 }
7743
7744 break;
7745 }
7746 case BOARD_PAGE_WEAPON:
7747 for (int i = 0; i < 6; i++) {
7748 CDngStatusData *status = BtlMenuStatusPt;
7749 WEAPON_HAVE *weapons = status->chara_weapons[i];
7750 WEAPON_HAVE *weapon = &weapons[10];
7751
7752 if (weapon->item_no >= ITEM_WEAPON_START) {
7753 message = GetWeaponMsgNo2(weapon->item_no) + 0x1F4;
7754 value = weapon->level;
7755 break;
7756 }
7757 }
7758
7759 break;
7760 case BOARD_PAGE_ATTACH: {
7761 ATTACH_LIST *attach = (ATTACH_LIST *) BtlMenuStatusPt->consumable_items + cursor + 40;
7762
7763 if (attach->item_no >= ITEM_ATTACH_START) {
7764 message = attach->item_no + 0x1F4;
7765
7766 if (attach->item_no == ITEM_ATTACH_SYNTHESIS_SPHERE) {
7767 name_mes = GetWeaponMsgNo2(attach->sphere_weapon_no);
7768 }
7769
7770 value = GetAttachVolumeForMsg(attach);
7771 }
7772
7773 break;
7774 }
7775 }
7776
7777 break;
7778 case ITEM_MENU_BOARD:
7779 switch (board->cursor_area) {
7780 case PERSONAL_BOARD_AREA_CELLS:
7781 switch (board->page) {
7782 case BOARD_PAGE_ITEM: {
7783 s16 *slot = &MenuItemPackPt->item[cursor];
7784
7785 if (*slot >= ITEM_DUNGEON_START) {
7786 message = *slot + 0x1F4;
7787 }
7788
7789 break;
7790 }
7791 case BOARD_PAGE_WEAPON: {
7792 int chara = board->cursor / 10;
7793 CDngStatusData *status = BtlMenuStatusPt;
7794 WEAPON_HAVE *row = status->chara_weapons[chara];
7795 WEAPON_HAVE *weapon = &row[board->cursor % 10];
7796
7797 if (weapon->item_no >= ITEM_WEAPON_START) {
7798 message = GetWeaponMsgNo2(weapon->item_no) + 0x1F4;
7799 value = weapon->level;
7800 }
7801
7802 break;
7803 }
7804 case BOARD_PAGE_ATTACH: {
7805 ATTACH_LIST *attach = (ATTACH_LIST *) &board->consumables[ItemMenuMode.board.cursor];
7806
7807 if (attach->item_no >= ITEM_ATTACH_START) {
7808 message = attach->item_no + 0x1F4;
7809 value = GetAttachVolumeForMsg(attach);
7810
7811 if (attach->item_no == ITEM_ATTACH_SYNTHESIS_SPHERE) {
7812 name_mes = GetWeaponMsgNo2(attach->sphere_weapon_no);
7813 }
7814 }
7815
7816 break;
7817 }
7818 }
7819
7820 break;
7821 case PERSONAL_BOARD_AREA_TRASH:
7822 if (BtlHaveItemPt->item_no < ITEM_ATTACH_START) {
7823 message = 0xBE;
7824 }
7825
7826 break;
7827 }
7828
7829 break;
7830 }
7831
7832 if (message < 0) {
7833 message = 0;
7834 }
7835
7836 if (ItemMenuMode.state != ITEM_MENU_STATE_DEBUG_ITEMS) {
7837 int remake = 0;
7838
7839 if (CommonMenuMes2.mes_made != message) {
7840 remake = 1;
7841 }
7842
7843 int made_no = CommonMenuMes2.mes_no[0];
7844 int made_value = CommonMenuMes2.value;
7845
7846 if ((name_mes > 0 && made_no != name_mes + 0x64) || (value >= 0 && made_value != value) || (chara_mes >= 0 && made_no != chara_mes + 0x32)) {
7847 remake = 1;
7848 }
7849
7850 if (remake != 0) {
7851 CommonMenuMes2.value_signed = true;
7852 CommonMenuMes2.value_show = false;
7853 CommonMenuMes2.value = value;
7854
7855 if (name_mes > 0) {
7856 CommonMenuMes2.mes_no[0] = name_mes + 0x64;
7857 }
7858
7859 if (chara_mes >= 0) {
7860 CommonMenuMes2.mes_no[0] = chara_mes + 0x32;
7861 }
7862
7863 CommonMenuMes2.mes_made = -1;
7864 CommonMenuMes2.MakeMesWin(message);
7865 }
7866 }
7867
7868 if (ItemMenuMode.overflow == 0) {
7869 switch (ItemMenuMode.mode) {
7870 case ITEM_MENU_QUICK_SLOTS:
7871 case ITEM_MENU_CHARA:
7872 case ITEM_MENU_WEAPON:
7873 case ITEM_MENU_DEFENSE:
7874 case ITEM_MENU_BOARD:
7875 case ITEM_MENU_TRUSH: {
7876 s16 names[6] = {0xB4, 0xB6, 0xB6, 0xB6, 0xB5, 0xB6};
7877 int made = AtoraNameMes.mes_made;
7878 s16 name = names[ItemMenuMode.mode];
7879
7880 if (made != name) {
7881 AtoraNameMes.MakeMesWin(name);
7882 }
7883
7884 break;
7885 }
7886 }
7887 }
7888
7889 return 1;
7890}
7891
7892void ItemMenuModeDraw() {
7893 BtlMenuTexBlockEnter();
7894 CharaStatus = TexManager.GetTexture("status", -1);
7895
7896 switch (ItemMenuMode.mode) {
7897 case ITEM_MENU_QUICK_SLOTS:
7898 case ITEM_MENU_CHARA:
7899 case ITEM_MENU_WEAPON:
7900 case ITEM_MENU_DEFENSE:
7901 case ITEM_MENU_BOARD:
7902 case ITEM_MENU_TRUSH: {
7903 ActiveItemDraw(0x3A, 0x4A, 0x80);
7904 DrawPersonalBoard(0x154, 0x78, ItemMenuMode.board.page, 0x80, 0);
7905 CommonTrushDraw(0x232, 0x10C, 0x80);
7906 CommonMoneyBoardDraw(0x163, 0x120, ((CUserStatus *) BtlMenuStatusPt)->money, 0x80);
7907 DrawTrushItem();
7908 IconAutoGet.IconAutoMove();
7909 IconAutoGet.IconAutoMoveDraw();
7910 ItemMenuCharaStatusDraw(0x3A, 0xB4, ItemMenuMode.chara, 0x80);
7911 MenuTextureReload(BtlMenuReadBlock);
7912 int arrow_x = -1;
7913 int arrow_y = arrow_x;
7914 int arrow_w = arrow_x;
7915
7916 switch (ItemMenuMode.mode) {
7917 case ITEM_MENU_QUICK_SLOTS:
7918 case ITEM_MENU_CHARA:
7919 case ITEM_MENU_WEAPON:
7920 case ITEM_MENU_DEFENSE:
7921 if (BtlMenuStatusPt->party_size > 1) {
7922 arrow_x = 0x32;
7923 arrow_y = 0x9C;
7924 arrow_w = 0xE8;
7925 }
7926
7927 break;
7928 case ITEM_MENU_BOARD:
7929 case ITEM_MENU_TRUSH:
7930 arrow_x = 0x146;
7931 arrow_y = 0x2A;
7932 arrow_w = 0xE6;
7933 break;
7934 }
7935
7936 if (0 < arrow_x) {
7937 DrawBtlMenuLRCursor(arrow_x, arrow_y, arrow_w, 0x80);
7938 }
7939
7940 break;
7941 }
7942 }
7943
7944 if (ItemMenuMode.overflow == 0) {
7945 MenuTextureReload(AtoraNameMes.tex_block);
7946#ifdef PAL
7947 float widths[7] = {11.4f, 12.7f, 12.7f, 12.9f, 12.7f, 12.7f, 12.7f};
7948 s8 shift[7] = {0, 0, 0, 0, 0, -16, -16};
7949 float heights[7] = {1.2f, 1.2f, 1.2f, 1.2f, 1.2f, 2.4f, 2.4f};
7950 MenuHelpWinDraw(0x36, 0x174 + shift[BtlMenuNowLang], widths[BtlMenuNowLang], heights[BtlMenuNowLang], 0x80);
7951#else
7952 float widths[7] = {11.4f, 12.7f, 12.7f, 12.7f, 12.7f, 12.7f, 12.7f};
7953 MenuHelpWinDraw(0x36, 0x154, widths[BtlMenuNowLang], 1.2f, 0x80);
7954#endif
7955 AtoraNameMes.stay_frame = false;
7956 AtoraNameMes.text_x = 0x4A;
7957#ifdef PAL
7958 AtoraNameMes.text_y = 0x178;
7959#else
7960 AtoraNameMes.text_y = 0x158;
7961#endif
7962 AtoraNameMes.edge_alpha = 0x80;
7963 AtoraNameMes.Step();
7964 AtoraNameMes.DrawMesWin();
7965 }
7966
7967 MenuTextureReload(BtlMenuReadBlock);
7968
7969 if (ItemMenuMode.state == ITEM_MENU_STATE_DEBUG_ITEMS) {
7970 DebugItemGetDraw();
7971 }
7972
7973 s16 cursor_pos[7][2] = {
7974 {0, 0x68},
7975 {0xB2, 0xE2},
7976 {0x2D, 0xBF},
7977 {0x59, 0xBF},
7978 {0, 0 },
7979 {0x11A, 0 },
7980 {0, 0 }
7981 };
7982 cursor_pos[0][0] = (ItemMenuMode.board.cursor << 6) + 0x3E;
7983 cursor_pos[5][1] = ItemMenuMode.board.cursor * 0x2C + 0x7E;
7984 int x = cursor_pos[ItemMenuMode.mode][0];
7985 int y = cursor_pos[ItemMenuMode.mode][1];
7986 PERSONAL_BOARD *board = &ItemMenuMode.board;
7987
7988 switch (ItemMenuMode.mode) {
7989 case ITEM_MENU_BOARD:
7990 switch (board->cursor_area) {
7991 case PERSONAL_BOARD_AREA_CELLS: {
7992 int cursor = board->cursor;
7993 x = cursor % 5 * 0x28 + 0x148;
7994 cursor -= board->top_row * 5;
7995 y = cursor / 5 * 0x28 + 0x7C;
7996 break;
7997 }
7998 case PERSONAL_BOARD_AREA_TRASH:
7999 x = 0x216;
8000 y = 0x110;
8001 break;
8002 }
8003
8004 break;
8005 }
8006
8007 int frame_w = 0x2A;
8008 int frame_h = 0x22;
8009 int frame_x = x + 0x17;
8010 int frame_y = y - 2;
8011
8012 if (ItemMenuMode.mode == ITEM_MENU_CHARA) {
8013 frame_h = 0x68;
8014 frame_w = frame_h;
8015 frame_x = x + 0xE;
8016 frame_y = y - 0x26;
8017 }
8018
8019 int vibe = 0;
8020
8021 if (board->held_item.item_no >= ITEM_ATTACH_START) {
8022 vibe = 2;
8023 } else {
8024 switch (ItemMenuMode.mode) {
8025 case ITEM_MENU_QUICK_SLOTS: {
8026 int cursor = ItemMenuMode.board.cursor;
8027 s16 *slot = &MenuItemPackPt->quick_item_slot[cursor];
8028
8029 if (0 <= cursor && *slot >= ITEM_DUNGEON_START) {
8030 vibe = 1;
8031 }
8032
8033 break;
8034 }
8035 case ITEM_MENU_TRUSH:
8036 case ITEM_MENU_BOARD:
8037 int cursor = ItemMenuMode.board.cursor;
8038
8039 if (SearchBoardNowPosItemExist(ItemMenuMode.board.page, cursor) >= ITEM_ATTACH_START) {
8040 vibe = 1;
8041 }
8042
8043 if (ItemMenuMode.board.cursor_area == PERSONAL_BOARD_AREA_TRASH && board->held_item.item_no < ITEM_ATTACH_START) {
8044 vibe = 0;
8045 }
8046
8047 break;
8048 }
8049 }
8050
8051 s16 vibe_offset[3][2] = {
8052 {0, 0 },
8053 {0x18, 0x18},
8054 {0x1C, 0x0D}
8055 };
8056 x += vibe_offset[vibe][0];
8057 y += vibe_offset[vibe][1];
8058 vibe = (vibe << 5) + 0x40;
8059 SysCur[0] += ((float) x - SysCur[0]) / 4.0f;
8060 SysCur[1] += ((float) y - SysCur[1]) / 4.0f;
8061 int big = 1;
8062
8063 if (vibe >= 0x80) {
8064 big = 0;
8065 }
8066
8067 if (board->held_item.item_no >= ITEM_ATTACH_START && ItemMenuMode.state != ITEM_MENU_STATE_POWERUP_CONFIRM) {
8068 ItemNaviCursor(board->held_item.item_no);
8069 COM_ITEM_INFO *info = GetCommonItemInfo(board->held_item.item_no);
8070
8071 if (info != NULL && (info->kind == ITEMKIND_WEAPON || info->kind == ITEMKIND_ATTACH)) {
8072 MenuTextureReload(ItemMenuWeaponIconReadBlock);
8073 }
8074
8075 DrawMenuVibeItem((int) SysCur[0], (int) SysCur[1], 2, -0xC, 0x80);
8076 }
8077
8078 switch (ItemMenuMode.state) {
8079 case ITEM_MENU_STATE_LOADING:
8080 case ITEM_MENU_STATE_OPEN:
8081 case ITEM_MENU_STATE_CLOSE: {
8082 int alpha = 0;
8083
8084 switch (ItemMenuMode.state) {
8085 case ITEM_MENU_STATE_LOADING:
8086 alpha = 0x80;
8087 break;
8088 case ITEM_MENU_STATE_OPEN:
8089 alpha = 0x80 - ItemMenuMode.counter * 8;
8090 break;
8091 case ITEM_MENU_STATE_CLOSE:
8092 alpha = ItemMenuMode.counter * 5 + 0x40;
8093 break;
8094 }
8095
8096 if (alpha < 0) {
8097 alpha = 0;
8098 }
8099
8100 if (alpha > 0x80) {
8101 alpha = 0x80;
8102 }
8103
8104 FrameImageDraw(0x40, alpha);
8105 break;
8106 }
8107 case ITEM_MENU_STATE_POWERUP_CONFIRM: {
8108 WEAPON_HAVE *weapon = ItemMenuMode.target_weapon;
8109 int filled = 0;
8110 int holes = GetWeaponHoleNum(weapon->item_no);
8111
8112 for (int i = 0; i < holes; i++) {
8113 if (weapon->attach[i].item_no >= ITEM_ATTACH_START) {
8114 filled++;
8115 }
8116 }
8117
8118 CommonMenuMes1.value_show = true;
8119
8120 if (CommonMenuMes1.mes_made != 0xBC || CommonMenuMes1.values[0] != filled || CommonMenuMes1.values[1] != holes) {
8121 for (int i = 0; i < 10; i++) {
8122 CommonMenuMes1.mes_no[i] = -1;
8123 CommonMenuMes1.values[i] = 0;
8124 }
8125
8126 CommonMenuMes1.value_signed = false;
8127 CommonMenuMes1.mes_made = -1;
8128 CommonMenuMes1.values[0] = filled;
8129 CommonMenuMes1.values[1] = holes;
8130 CommonMenuMes1.MakeMesWin(0xBC);
8131 }
8132
8133 switch (ItemMenuMode.use_target) {
8134 case ITEM_USE_ON_EQUIP_WEAPON:
8135 case ITEM_USE_ON_BOARD_WEAPON: {
8136 CommonMenuMes1.stay_frame = true;
8137 MenuTextureReload(CommonMenuMes1.tex_block);
8138 CommonMenuMes1.auto_pos = MES_POS_AUTO;
8139 CommonMenuMes1.text_x = 0xE2;
8140 CommonMenuMes1.text_y = 0x92;
8141 CommonMenuMes1.Step();
8142 CommonMenuMes1.DrawMesWin();
8143 setbilinear(0);
8144 MenuTextureReload(BtlMenuReadBlock);
8145 int hole_x = 0x13C - (holes * 0x12 + 0xA);
8146 DrawWepHole(hole_x, 0x5A, weapon, 1, 0x80);
8147 MenuTextureReload(ItemMenuWeaponIconReadBlock);
8148 DrawWepAttach(hole_x + 0xE, 0x60, weapon, 1, 0x80);
8149 MenuTextureReload(BtlMenuReadBlock);
8150 DrawDngYesNoDialog(0x114, 0xE6, 0x80);
8151 int yes_y = ItemMenuMode.confirm * 0x1C + 0xE0;
8152 DrawMenuWaku(268.0f, (float) (yes_y - 2), 0x60, 0x18, 0, StayTex, 0x80);
8153 DrawMenuObjectVibe(0xF2, yes_y, 0, 0x40);
8154 break;
8155 }
8156 }
8157
8158 break;
8159 }
8160 default:
8161 if (ItemMenuMode.state != ITEM_MENU_STATE_DEBUG_ITEMS && ItemMenuMode.state != ITEM_MENU_STATE_EFFECT) {
8162 DrawMenuWaku((float) frame_x, (float) frame_y, frame_w, frame_h, 0, StayTex, 0x80);
8163 DrawMenuObjectVibe((int) SysCur[0], (int) SysCur[1], big, vibe);
8164 }
8165
8166 break;
8167 }
8168}
8169
8170int ItemMenuModeKey() {
8171 if (ItemMenuMode.mode == ITEM_MENU_TRUSH) {
8172 int count = TrushMoveMax[ItemMenuMode.board.page];
8173
8174 if (count <= ItemMenuMode.board.cursor) {
8175 ItemMenuMode.board.cursor = count - 1;
8176 }
8177 }
8178
8179 if (GamePad.Down(PAD_UP) != 0) {
8180 switch (ItemMenuMode.mode) {
8181 case ITEM_MENU_WEAPON:
8182 case ITEM_MENU_DEFENSE:
8183 ItemMenuMode.board.cursor = 0;
8184 ItemMenuMode.mode = ITEM_MENU_QUICK_SLOTS;
8185 break;
8186 case ITEM_MENU_TRUSH:
8187 if (0 < ItemMenuMode.board.cursor) {
8188 ItemMenuMode.board.cursor--;
8189 }
8190
8191 if (ItemMenuMode.board.cursor < 0) {
8192 ItemMenuMode.board.cursor = 0;
8193 }
8194
8195 break;
8196 default:
8197 ItemMenuMode.board.cursor = 1;
8198 ItemMenuMode.mode = ITEM_MENU_QUICK_SLOTS;
8199 break;
8200 }
8201 }
8202
8203 if (GamePad.Down(PAD_DOWN) != 0) {
8204 switch (ItemMenuMode.mode) {
8205 case ITEM_MENU_TRUSH: {
8206 ItemMenuMode.board.cursor++;
8207 int count = ItemMenuMode.overflow_count[ItemMenuMode.board.page];
8208
8209 if (count <= ItemMenuMode.board.cursor) {
8210 ItemMenuMode.board.cursor = count - 1;
8211 }
8212
8213 if (ItemMenuMode.board.cursor < 0) {
8214 ItemMenuMode.board.cursor = 0;
8215 }
8216
8217 break;
8218 }
8219 case ITEM_MENU_QUICK_SLOTS:
8220 if (ItemMenuMode.board.cursor == 0) {
8221 ItemMenuMode.mode = ITEM_MENU_WEAPON;
8222 break;
8223 }
8224 default:
8225 ItemMenuMode.mode = ITEM_MENU_CHARA;
8226 break;
8227 }
8228 }
8229
8230 if (GamePad.Down(PAD_LEFT) != 0) {
8231 switch (ItemMenuMode.mode) {
8232 case ITEM_MENU_QUICK_SLOTS:
8233 if (0 < ItemMenuMode.board.cursor) {
8234 ItemMenuMode.board.cursor--;
8235 }
8236
8237 break;
8238 case ITEM_MENU_DEFENSE:
8239 ItemMenuMode.mode = ITEM_MENU_WEAPON;
8240 break;
8241 case ITEM_MENU_CHARA:
8242 ItemMenuMode.mode = ITEM_MENU_DEFENSE;
8243 break;
8244 case ITEM_MENU_TRUSH:
8245 ItemMenuMode.mode = ITEM_MENU_CHARA;
8246 ItemMenuMode.board.cursor = 0;
8247 break;
8248 }
8249 }
8250
8251 if (GamePad.Down(PAD_RIGHT) != 0) {
8252 int old_mode = ItemMenuMode.mode;
8253
8254 switch (ItemMenuMode.mode) {
8255 case ITEM_MENU_TRUSH:
8256 ItemMenuMode.mode = ITEM_MENU_BOARD;
8257 ItemMenuMode.board.cursor_area = PERSONAL_BOARD_AREA_CELLS;
8258 ItemMenuMode.board.cursor = (ItemMenuMode.board.top_row + ItemMenuMode.board.cursor) * 5;
8259 break;
8260 case ITEM_MENU_QUICK_SLOTS:
8261 if (ItemMenuMode.board.cursor < 2) {
8262 ItemMenuMode.board.cursor++;
8263 } else {
8264 ItemMenuMode.mode = ITEM_MENU_BOARD;
8265 ItemMenuMode.board.cursor_area = PERSONAL_BOARD_AREA_CELLS;
8266 ItemMenuMode.board.cursor = ItemMenuMode.board.top_row * 5;
8267 }
8268
8269 break;
8270 case ITEM_MENU_WEAPON:
8271 ItemMenuMode.mode = ITEM_MENU_DEFENSE;
8272 break;
8273 case ITEM_MENU_DEFENSE:
8274 ItemMenuMode.mode = ITEM_MENU_CHARA;
8275 break;
8276 case ITEM_MENU_CHARA:
8277 ItemMenuMode.mode = ITEM_MENU_BOARD;
8278 ItemMenuMode.board.cursor_area = PERSONAL_BOARD_AREA_CELLS;
8279 ItemMenuMode.board.cursor = ItemMenuMode.board.top_row * 5 + 5;
8280 break;
8281 }
8282
8283 if (old_mode != ITEM_MENU_TRUSH && ItemMenuMode.mode == ITEM_MENU_BOARD) {
8284 int rows[4] = {0, 2, 0, 0};
8285
8286 if ((ItemMenuMode.overflow_pages & (1 << (ItemMenuMode.board.page + 1))) && ItemMenuMode.overflow != 0) {
8287 ItemMenuMode.board.cursor = rows[old_mode];
8288
8289 if (ItemMenuMode.board.cursor > ItemMenuMode.overflow_count[ItemMenuMode.board.page] - 1) {
8290 ItemMenuMode.board.cursor = ItemMenuMode.overflow_count[ItemMenuMode.board.page] - 1;
8291 }
8292
8293 ItemMenuMode.mode = ITEM_MENU_TRUSH;
8294 }
8295 }
8296 }
8297
8298 return 0;
8299}
8300
8301void ActiveItemDraw(int x, int y, int alpha) {
8302 RECT digits = {0x90, 0xDC, 0xC, 0xC};
8303
8304 MenuTextureReload(ItemMenuWeaponIconReadBlock);
8305 int slot_x = x + 0xE;
8306 int slot_y;
8307 DrawMenu2DSprite(CharaStatus, CRect_i_(slot_x, y + 1, 0xE0, 0x4F), CRect_i_(0, 0, 0xE0, 0x50), alpha);
8308 s16 *items = MenuItemPackPt->quick_item_slot;
8309 s16 *counts = MenuItemPackPt->quick_item_qty;
8310
8311 for (int i = 0; i < 3; i++) {
8312 s16 item_no = items[i];
8313
8314 if (item_no >= ITEM_DUNGEON_START) {
8315 if (item_no >= ITEM_DUNGEON_START) {
8316 slot_x = x + 0x22 + (i << 6);
8317 }
8318
8319 slot_y = y + 0x1F;
8320 DrawMenu2DSprite(CharaStatus, CRect_i_(slot_x, slot_y, 0x2C, 0x2C), CRect_i_(0x128, 0, 0x2C, 0x2C), alpha);
8321 DrawIconParts(item_no, slot_x + 6, slot_y + 6, 0, 0x280, alpha, 0);
8322 s16 count = counts[i];
8323
8324 if (count >= 2) {
8325 DrawMenuNumber(count, slot_x + 0x26, slot_y + 0x1E, PerBoardTex, digits, 0, alpha);
8326 }
8327 }
8328 }
8329
8330 switch (BtlMenuMode) {
8331 case BATTLE_MENU_MODE_DUNGEON:
8332 DngActiveItemTextureCopy();
8333 break;
8334 }
8335}
8336
8344static void MenuCharaPolyDraw() {
8345 SetNowCharaMotionNo(ItemMenuMode.chara);
8346 SetItemMenuColor(ItemMenuMode.chara);
8347 MenuCharaFrame.Step();
8348
8349 if (ItemMenuMode.chara == 0) {
8350 MenuCharaFrame.ClothStep(0);
8351 }
8352
8353 MenuCharaFrame.Draw();
8354 SetItemMenuOldAmbient();
8355}
8356
8357void ItemMenuCharaStatusDraw(int x, int y, int chara, int alpha) {
8358 int draw_x;
8359 int draw_y;
8360
8361 if (CharaStatus != NULL) {
8362 MenuTextureReload(ItemMenuWeaponIconReadBlock);
8363 DrawMenu2DSprite(CharaStatus, CRect_i_(x, y + 1, 0xFC, 0x85), CRect_i_(0, 0x50, 0xFC, 0x86), alpha);
8364 int level = BtlMenuStatusPt->defense[chara];
8365 RECT number_rect = {0x100, 0x60, 0xC, 0xE};
8366 DrawMenuNumber(level, x + 0x64, y + 0x24, CharaStatus, number_rect, 1, alpha);
8367
8368 if (MenuExTextureReadFlag == MENU_EX_TEX_READY && chara < BtlMenuStatusPt->party_size) {
8369 MenuTextureReload(MenuExtendReadBlock);
8370 MGSetWindowRect(CRect_i_(x + 0x82, 0x5D, 0x76, 0x3F));
8371 MenuPolygonDraw(alpha, MenuCharaPolyDraw);
8372 MGSetWindowRect();
8373 spRGBA top;
8374 spRGBA bottom;
8375 top.r = top.g = top.b = bottom.r = bottom.g = bottom.b = 0x80;
8376 top.a = 0;
8377 bottom.a = alpha;
8378 MenuTextureReload(ItemMenuWeaponIconReadBlock);
8379 draw_x = x + 0x7E;
8380 draw_y = y + 0x6E;
8381 set2DSprite(GetVif1Packet(), CharaStatus, CRect_i_(draw_x, draw_y + 1, 0x7E, 0x17), CRect_i_(0x7E, 0xBE, 0x7E, 0x18), &top, &top, &bottom, &bottom, 1);
8382 }
8383
8384 MenuTextureReload(BtlMenuReadBlock);
8385 draw_x = x + 0x6E;
8386 draw_y = y + 0x14;
8387 CharaStatusMsgDraw(draw_x, draw_y, chara, 0, alpha);
8388 CDngStatusData *status = BtlMenuStatusPt;
8389 int hp = status->hp[chara];
8390 int max_hp = status->max_hp[chara];
8391
8392 if (max_hp <= 0) {
8393 max_hp = 1;
8394 }
8395
8396 WEAPON_HAVE *weapon;
8397 int slot = status->equipped_weapon_slot[chara];
8398
8399 if (slot < 0) {
8400 weapon = &ItemMenuMode.board.weapon;
8401 } else {
8402 WEAPON_HAVE *row = status->chara_weapons[chara];
8403 weapon = &row[slot];
8404 }
8405
8406 float durability;
8407 float durability_max;
8408 durability_max = durability = 0.0f;
8409
8410 if (weapon != NULL) {
8411 durability = weapon->durability_f;
8412 durability_max = weapon->durability;
8413 }
8414
8415 if (durability_max < 0.0f) {
8416 durability_max = 1.0f;
8417 }
8418
8419 MenuTextureReload(ItemMenuWeaponIconReadBlock);
8420 int hp_width = max_hp * 153 / 200;
8421 int durability_width = 153.0f * durability_max / 99.0f;
8422 CRect_i_ bar_src(0x154, 0, 4, 0x10);
8423 draw_y = y + 0x41;
8424 DrawMenu2DSprite(CharaStatus, CRect_i_(x + 0x22, draw_y, hp_width, 0x10), bar_src, alpha);
8425 DrawMenu2DSprite(CharaStatus, CRect_i_(x + 0x1A + hp_width, draw_y, 0xA, 0x10), CRect_i_(0x154, 0, 0xA, 0x10), alpha);
8426 draw_y = y + 0x51;
8427 DrawMenu2DSprite(CharaStatus, CRect_i_(x + 0x22, draw_y, durability_width, 0x10), bar_src, alpha);
8428 DrawMenu2DSprite(CharaStatus, CRect_i_(x + 0x1A + durability_width, draw_y, 0xA, 0x10), CRect_i_(0x158, 0, 0xA, 0x10), alpha);
8429 float thirst_value = BtlMenuStatusPt->water_max[chara];
8430 int thirst = thirst_value / 10.0f;
8431 draw_x = x + 0x1E;
8432 draw_y = y + 0x62;
8433
8434 for (int i = 0; i < thirst - 1; i++) {
8435 DrawMenu2DSprite(CharaStatus, CRect_i_(draw_x, draw_y + 2, 0x12, 0x15), CRect_i_(0x154, 0x10, 0x12, 0x14), alpha);
8436 draw_x += 0x12;
8437 }
8438
8439 DrawMenu2DSprite(CharaStatus, CRect_i_(draw_x, draw_y + 2, 0x18, 0x15), CRect_i_(0x166, 0x10, 0x18, 0x14), alpha);
8440 draw_x = x + 0x1F;
8441 draw_y = y + 0x47;
8442 float hp_fill = (float) (hp_width * hp) / (float) max_hp;
8443 int color = 0;
8444 float low_hp = 0.3f * (float) max_hp;
8445
8446 if ((float) hp < low_hp) {
8447 color++;
8448 }
8449
8450 if ((float) hp < 0.15f * (float) max_hp) {
8451 color++;
8452 }
8453
8454 GRADATION_COLOR_INFO2 *info = GetGradationColorInfo2(color + 0x16);
8455 GRADATION_COLOR_INFO2 gradation;
8456 memcpy(&gradation, info, sizeof(gradation));
8457 gradation.colors[3].a = alpha;
8458 gradation.colors[2].a = alpha;
8459 gradation.colors[1].a = alpha;
8460 gradation.colors[0].a = alpha;
8461 DrawMenuColorGradation(CRect_i_(draw_x, draw_y - 1, (int) hp_fill, 6), &info->colors[0], &info->colors[1], &info->colors[2], &info->colors[3]);
8462 int values[2] = {hp, max_hp};
8463 draw_x = x + 0x3C + hp_width;
8464 draw_y = y + 0x47;
8465 DrawStatusNumberNowAndMax(values, draw_x, draw_y, 1, alpha);
8466 int motion;
8467 int now_motion = MenuCharaFrame.motion_no;
8468
8469 if (hp_fill < low_hp) {
8470 motion = 1;
8471 } else {
8472 motion = 0;
8473 }
8474
8475 if (motion != now_motion) {
8476 MenuCharaFrame.SetMotion(motion, 0);
8477 }
8478
8479 draw_x = x + 0x1F;
8480 draw_y = y + 0x56;
8481 hp_fill = (float) durability_width * durability / durability_max;
8482 int durability_color;
8483
8484 if (durability < 0.3f * durability_max) {
8485 durability_color = 0x1A;
8486 } else {
8487 durability_color = 0x19;
8488 }
8489
8490 info = GetGradationColorInfo2(0x19);
8491 memcpy(&gradation, info, sizeof(gradation));
8492 gradation.colors[3].a = alpha;
8493 gradation.colors[2].a = alpha;
8494 gradation.colors[1].a = alpha;
8495 gradation.colors[0].a = alpha;
8496 DrawMenuColorGradation(CRect_i_(draw_x, draw_y, (int) hp_fill, 6), &gradation.colors[0], &gradation.colors[1], &gradation.colors[2], &gradation.colors[3]);
8497 draw_x = x + 0x3C + durability_width;
8498 draw_y = y + 0x57;
8499 values[0] = GetDispVolumeForFloat(durability);
8500 values[1] = (int) durability_max;
8501 DrawStatusNumberNowAndMax(values, draw_x, draw_y, 1, alpha);
8502 draw_x = x + 0x20;
8503 draw_y = y + 0x60;
8504 int drops = (int) BtlMenuStatusPt->water_now[chara] / 10;
8505
8506 for (int i = 0; i < drops; i++) {
8507 DrawMenu2DSprite(CharaStatus, CRect_i_(draw_x, draw_y, 0x10, 0x14), CRect_i_(0x128, 0x2C, 0x10, 0x14), alpha);
8508 draw_x += 0x12;
8509 }
8510
8511 drops = (int) BtlMenuStatusPt->water_now[chara] % 10;
8512
8513 if (drops != 0) {
8514 DrawMenu2DSprite(CharaStatus, CRect_i_(draw_x, draw_y, 0x10, 0x14), CRect_i_(0x128 + (3 - (int) (drops / 2.5f)) * 0x10, 0x2C, 0x10, 0x14), alpha);
8515 }
8516
8517 draw_y = y - 0x14;
8518 int party_size = BtlMenuStatusPt->party_size;
8519 int tab = 0;
8520 int i = 0;
8521 int after = 0;
8522 int tex_x;
8523 int tex_y;
8524
8525 for (; i <= party_size; i++) {
8526 if (tab == chara) {
8527 if (after != 0) {
8528 draw_x = x + 0x10 + chara * 0xC;
8529 DrawMenu2DSprite(CharaStatus, CRect_i_(draw_x, draw_y - 1, 0x20, 0x1B), CRect_i_(0, 0xD8, 0x20, 0x1C), alpha);
8530 DrawMenu2DSprite(CharaStatus, CRect_i_(draw_x + 0x20, draw_y - 1, 0x5E, 0x1B), CRect_i_(0x20, 0xD8, 0x4A, 0x1C), alpha);
8531 DrawMenu2DSprite(CharaStatus, CRect_i_(draw_x + 0x7E, draw_y - 1, 0x20, 0x1B), CRect_i_(0x6A, 0xD8, 0x20, 0x1C), alpha);
8532 } else {
8533 after = 1;
8534 tab = party_size - 1;
8535 }
8536 } else {
8537 draw_x = tab * 0xC + (x + 0x10 + after * 0x69);
8538 draw_y = y - 0x14;
8539 tex_y = 0xD8;
8540
8541 if (after == 0) {
8542 tex_x = 0xA6;
8543 tab++;
8544 } else {
8545 tex_x = 0x8A;
8546 tab--;
8547
8548 if (GetMenuLangFlag() > LANG_JAPANESE) {
8549 draw_x += 0x14;
8550 }
8551 }
8552
8553 DrawMenu2DSprite(CharaStatus, CRect_i_(draw_x, draw_y + 2, 0x1C, 0x13), CRect_i_(tex_x, tex_y, 0x1C, 0x14), alpha);
8554 }
8555 }
8556
8557 int item_no = weapon->item_no;
8558 draw_x = x + 0x16;
8559 draw_y = y + 0x10;
8560 RetCTex(item_no, tex_x, tex_y);
8561 CTexture *icon = TexManager.GetTexture("wepicon", -1);
8562
8563 if (icon != NULL && item_no >= ITEM_WEAPON_START) {
8564 MenuTextureReload(ItemMenuWeaponIconReadBlock);
8565 WEAPON_HAVE total;
8566 WeaponAllValueSet(weapon, &total, 0);
8567 DrawMenu2DSprite(icon, CRect_i_(draw_x, draw_y, 0x20, 0x20), CRect_i_(tex_x, tex_y, 0x20, 0x20), alpha);
8568 DrawMenuNumber(total.attack, draw_x + 0x20, draw_y + 0x14, CharaStatus, number_rect, 1, alpha);
8569 }
8570
8571 MenuTextureReload(CommonMenuMes3.tex_block);
8572 int mes_no = chara + 0xC2;
8573
8574 if (CommonMenuMes3.mes_made != mes_no) {
8575 CommonMenuMes3.MakeMesWin(mes_no);
8576 }
8577
8578 int name_length = GetMsgLengthCharaName(chara);
8579 CommonMenuMes3.edge_alpha = alpha;
8580 CommonMenuMes3.stay_frame = false;
8581 s8 char_width[7] = {8, 6, 6, 6, 6, 6, 6};
8582 s8 name_offset[7] = {0, 6, 6, 6, 6, 6, 6};
8583 int lang = BtlMenuNowLang;
8584 DrawMenuClsMes(&CommonMenuMes3, x + 0x5A + chara * 0xC - name_length * char_width[lang] + name_offset[lang], y - 0x12);
8585 }
8586}
8587
8588void ItemNaviCursor(int item_no) {
8589 s8 shown[3] = {0, 0, 0};
8590 ITEM_DATA *data = GetItemData(item_no);
8591
8592 if (data == NULL) {
8593 return;
8594 }
8595
8596 switch (data->sort_key) {
8597 case ITEM_SORT_FOOD:
8598 shown[0] = 1;
8599
8600 if (item_no >= ITEM_REGULAR_WATER && item_no <= ITEM_CHEESE) {
8601 shown[1] = 1;
8602 }
8603
8604 if (item_no == ITEM_MELLOW_BANANA) {
8605 shown[1] = 1;
8606 }
8607
8608 break;
8609 case ITEM_SORT_POWDER:
8610 if ((u32) (item_no - ITEM_REPAIR_POWDER) < 2) {
8611 shown[2] = 1;
8612 }
8613
8614 if (item_no == ITEM_REVIVAL_POWDER) {
8615 shown[1] = 1;
8616 int chara = ItemMenuMode.chara;
8617 CDngStatusData *status = BtlMenuStatusPt;
8618
8619 if ((float) status->hp[chara] <= 0.0f) {
8620 shown[0] = 1;
8621 }
8622 }
8623
8624 break;
8625 case ITEM_SORT_THROW:
8626 shown[1] = 1;
8627
8628 if (BtlMenuMode == BATTLE_MENU_MODE_DUNGEON && item_no >= ITEM_THROBBING_CHERRY && item_no < ITEM_MEDUSA_POWDER && item_no != ITEM_BOMB_NUTS) {
8629 shown[0] = 1;
8630 }
8631
8632 break;
8633 default:
8634 if (item_no == ITEM_DRAN_S_FEATHER) {
8635 shown[1] = 1;
8636 }
8637
8638 break;
8639 }
8640
8641 static int ct = 0;
8642 s16 pos[3][2] = {
8643 {0x104, 0xAC},
8644 {0x10C, 0x46},
8645 {0x64, 0xAA}
8646 };
8647 ct++;
8648
8649 for (int i = 0; i < 3; i++) {
8650 if (shown[i] != 0 && ct % 60 < 30) {
8651 int px = pos[i][0];
8652 int py = pos[i][1];
8653 CRect_i_ texel(0xD8, 0, 0x28, 0x14);
8654
8655 for (int j = 0; j < 2; j++, py -= 0x14, texel.x -= 0x28) {
8656 DrawMenu2DSprite(BtStatus, CRect_i_(px, py, texel.width, texel.height), texel, 0x80);
8657 }
8658 }
8659 }
8660
8661 if (ct >= 0x3C) {
8662 ct = 0;
8663 }
8664}
8665
8666void CharaStatusMsgDraw(int x, int y, int chara, int per_member, int alpha) {
8667 static float statusCnt = -PI;
8668
8669 int bob_y = (int) ((float) y + 4.0f * sinf(statusCnt));
8670 int condition;
8671 int icon = -1;
8672 condition = BtlMenuStatusPt->GetActiveCharaStatus(chara);
8673
8674 if (condition & AILMENT_GOO) {
8675 icon = 5;
8676 }
8677
8678 if (condition & AILMENT_CURSE) {
8679 icon = 2;
8680 }
8681
8682 if (condition & AILMENT_POISON) {
8683 icon = 4;
8684 }
8685
8686 if (condition & AILMENT_STAMINA) {
8687 icon = 1;
8688 }
8689
8690 if (condition & AILMENT_FREEZE) {
8691 icon = 3;
8692 }
8693
8694 if (BtlMenuStatusPt->hp[chara] <= 0 || (condition & AILMENT_KNOCKED_OUT)) {
8695 icon = 0;
8696 }
8697
8698 if (icon >= 0) {
8699 int u = icon / 3 * 0x44 + 0x78;
8700 int v = icon % 3 * 0x24 + 0x14;
8701 DrawMenu2DSprite(BtStatus, CRect_i_(x, bob_y, 0x44, 0x23), CRect_i_(u, v, 0x44, 0x24), alpha);
8702 }
8703
8704 float period;
8705
8706 if (per_member != 0) {
8707 float count = BtlMenuStatusPt->GetPartySize();
8708 period = 50.0f * count;
8709 } else {
8710 period = 50.0f;
8711 }
8712
8713 statusCnt += PI / period;
8714
8715 if (!(statusCnt < PI)) {
8716 statusCnt = -PI;
8717 }
8718}
8719
8727static int BattleMenuAtoraKey() {
8728 switch (BtlEffectFlag) {
8729 case BTLEFFECT_PAGE_OPEN:
8730 if (ToFromSelect(0) != 0) {
8731 BtlEffectFlag = BTLEFFECT_NONE;
8732 BtlEffectCt = 0.0f;
8733 }
8734
8735 break;
8736 case BTLEFFECT_PAGE_CLOSE:
8737 if (ToFromSelect(1) != 0) {
8738 MenuSelect[0] = BTLMENU_PAGE_ATLA;
8739 BattleMenuFlag = BTLMENU_STATE_ATLA_CLOSE;
8740 ForBackMenu();
8741 BattleMenuFlag = BTLMENU_STATE_MAIN;
8742 }
8743
8744 break;
8745 default:
8746 switch (MenuAtoraSelectKey()) {
8747 case ATORA_SELECT_CLOSE:
8748 BtlEffectFlag = BTLEFFECT_PAGE_CLOSE;
8749 BtlEffectCt = 0.0f;
8750 break;
8751 case ATORA_SELECT_NONE:
8752 break;
8753 }
8754
8755 break;
8756 }
8757
8758 if (BtlEffectFlag != BTLEFFECT_NONE) {
8759 BtlEffectCt += 1.0f;
8760 } else {
8761 BtlEffectCt = 0.0f;
8762 }
8763
8764 return 1;
8765}
8766
8767static int IsLoadMapNo();
8768
8769static int MapNoTransFunc(int map_no);
8770
8771s16 MenuGrobalMapNoTbl[16] = {0, 200, 1, 201, 14, 2, 202, 3, 42, 203, 23, 4, 204, 40, 205, 60};
8772WORLD_MAP_POS TownOrDngPos[16] = {
8773 {"e01", 0, 0, 0},
8774 {"d01", 0, 0, 0},
8775 {"e02", 0, 0, 0},
8776 {"d02", 0, 0, 0},
8777 {"s04", 0, 0, 0},
8778 {"e03", 0, 0, 0},
8779 {"d03", 0, 0, 0},
8780 {"e04", 0, 0, 0},
8781 {"s32", 0, 0, 0},
8782 {"d04", 0, 0, 0},
8783 {"s13", 0, 0, 0},
8784 {"e05", 0, 0, 0},
8785 {"d05", 0, 0, 0},
8786 {"s30", 0, 0, 0},
8787 {"d06", 0, 0, 0},
8788 {"xx", 0, 0, 0},
8789};
8790float mapo[4] = {0.0f, 0.0f, 0.0f, 1.0f};
8791float mapmovev[4] = {0.0f, 0.0f, 0.0f, 1.0f};
8792
8793char *NextWorldPos;
8794CFrame *MapMoveCursor;
8795CTexture *MenuMoveTex;
8796
8804static void StartLoadWorldMap(int region, u_long128 *buffer);
8805
8806void InitMenuMove(int mode, int texture_block, u_long128 *buffer) {
8807 BtlMenuSaveDataPt = SaveData;
8808 MenuMove.mode = mode;
8809
8810 switch (mode) {
8811 case MENU_MOVE_DUNGEON_ESCAPE:
8812 case MENU_MOVE_INTERIOR_OUT:
8813 MenuMapJumpMode = 0;
8814 MenuMove.cursor = 1;
8815 MenuMove.ready = 1;
8816 CommonMenuMes3.Preset(MES_PRESET_SYSTEM);
8817 CommonMenuMes3.rows = 3;
8818 CommonMenuMes3.auto_pos = MES_POS_NONE;
8819 SysCur[1] = MenuMove.cursor * 26 + 174;
8820 MapMoveCursor = NULL;
8821 MenuMoveTex = NULL;
8822 break;
8823 case MENU_MOVE_WORLD_MAP_DIRECT:
8824 BtlMenuStatusPt = BtlMenuSaveDataPt->GetDngStatus();
8825#ifdef PAL
8826 StayTex = TexManager.GetTexture("stayframe", -1);
8827#else
8828 StayTex = TexManager.GetTexture("stayfram", -1);
8829#endif
8830 GamePad.MenuModeOn(0x78);
8831 GamePad.SetAutoRepeat(PAD_DPAD, 30, 5);
8832 case MENU_MOVE_WORLD_MAP:
8833 if (((s32 *) SaveData->GetConfigData())[14] != 0 && SaveData->VisitMap(MenuGrobalMapNoTbl[WORLD_PLACE_FIELD_S30], 0) > 0) {
8834 printf("clear!!!!\n");
8835
8836 if (SaveData->VisitMap(MenuGrobalMapNoTbl[WORLD_PLACE_DEMON_SHAFT] <= 0, 0) != 0) {
8837 SaveData->VisitMap(MenuGrobalMapNoTbl[WORLD_PLACE_DEMON_SHAFT], 1);
8838 printf("demon shaft On!!!!!\n");
8839 }
8840 } else {
8841 if (((s32 *) SaveData->GetConfigData())[14] == 0) {
8842 printf("not clear \n");
8843 }
8844
8845 if (SaveData->QuestDungeon(5, 0) <= 0) {
8846 printf("not toki no kairou\n");
8847 }
8848 }
8849
8850 printf("MapNo = %d\n", MapNo);
8851 MenuMapJumpMode = -1;
8852 MenuMove.cursor = MapNoTransFunc(MapNo);
8853 MenuMove.start_place = MenuMove.cursor;
8854 MenuMove.load_map = IsLoadMapNo();
8855 printf("Now select map = %d\n", MenuMove.cursor);
8856 printf("Now Load MapNo = %d\n", MenuMove.load_map);
8857 NextWorldPos = TownOrDngPos[MenuMove.cursor].frame;
8858 MenuMove.tex_block = texture_block;
8859 buffer = MenuCalcBufAlignment(buffer);
8860 MenuMove.last_place = WORLD_PLACE_DEMON_SHAFT;
8861 StartLoadWorldMap(MenuMove.load_map, buffer);
8862
8863 if (mode == MENU_MOVE_WORLD_MAP_DIRECT) {
8864 do {
8865 } while (ReadBGSync() != 0);
8866 }
8867
8868 MenuMove.ready = 0;
8869 CommonMenuMes3.Preset(MES_PRESET_NAME);
8870 CommonMenuMes3.rows = 1;
8871 MapMoveCursor = NULL;
8872 break;
8873 case MENU_MOVE_FIRST_DUNGEON:
8874 MenuMove.cursor = 1;
8875 MenuMapJumpMode = -1;
8876 CommonMenuMes3.Preset(MES_PRESET_SYSTEM);
8877 CommonMenuMes3.rows = 3;
8878 SysCur[1] = MenuMove.cursor * 26 + 174;
8879 break;
8880 }
8881
8882 MenuMove.state = MENU_MOVE_STATE_OPEN;
8883 MenuMove.counter = 1;
8884 CommonMenuMes2.mes_made = -1;
8885 CommonMenuMes3.mes_made = -1;
8886}
8887
8888void GetTownOrDngPos() {
8889 MenuWorldTrans(&MenuCamera);
8890 float scale = 2.2f;
8891 MenuCharaFrame.SetScale(scale, scale, scale);
8892 MenuCharaFrame.SetPosition(mapo);
8893 float ref[4] = {0.0f, 0.0f, -45.0f, 1.0f};
8894 float pos[4] = {0.0f, 0.0f, 60.0f, 1.0f};
8895 MenuCamera.SetRef(ref);
8896 MenuCamera.SetPos(pos);
8897
8898 for (int i = 0; i < 16; i++) {
8899 WORLD_MAP_POS *place = &TownOrDngPos[i];
8900
8901 if (place != NULL) {
8902 if (GetVisitInfo(i, MenuMove.mode) == 0) {
8903 place->visited = -1;
8904 } else {
8905 place->visited = 1;
8906 }
8907
8908 CFrame *frame = MenuCharaFrame.frame->SearchFrame(place->frame);
8909
8910 if (frame == NULL) {
8911 printf("%d is NULL nothing\n", i);
8912 } else {
8913 int screen[2];
8914 Get3DPosTo2DPos(frame, screen);
8915 place->x = screen[0] - 4;
8916 place->y = screen[1] - 0x2A;
8917 }
8918 }
8919 }
8920}
8921
8922int MenuMoveKey() {
8923 int stay = 1;
8924 int decided = 0;
8925 int message = CommonMenuMes3.mes_made;
8926 int help = 0;
8927 int done;
8928
8929 switch (MenuMove.state) {
8930 case MENU_MOVE_STATE_OPEN: {
8931 done = ToFromSelect(0);
8932 int ready = 1;
8933
8934 switch (MenuMove.mode) {
8935 case MENU_MOVE_DUNGEON_ESCAPE:
8936 case MENU_MOVE_FIRST_DUNGEON:
8937 case MENU_MOVE_INTERIOR_OUT:
8938 MenuMove.ready = 1;
8939 break;
8940 case MENU_MOVE_WORLD_MAP:
8941 case MENU_MOVE_WORLD_MAP_DIRECT:
8942 if (MenuMove.ready == 0) {
8943 MenuMove.ready = LoadWorldMap();
8944
8945 if (MenuMove.ready != 0) {
8946 ComMenuSePlay(SE_WORLD_MAP_OPEN);
8947 }
8948
8949 ready = 0;
8950 } else {
8951 ready = 0;
8952
8953 if (MenuCharaFrame.motion_state == 3) {
8954 ready = 1;
8955 SysCur[0] = 328.0f;
8956 SysCur[1] = 164.0f;
8957 GetTownOrDngPos();
8958 }
8959 }
8960
8961 break;
8962 }
8963
8964 if (done != 0 && MenuMove.counter > 0x14 && MenuMove.ready != 0 && ready != 0) {
8965 switch (MenuMove.mode) {
8966 case MENU_MOVE_WORLD_MAP_DIRECT:
8967 break;
8968 default:
8969 BattleMenuFlag = BTLMENU_STATE_MOVE;
8970 break;
8971 }
8972
8973 MenuMove.state = MENU_MOVE_STATE_SELECT;
8974
8975 switch (MenuMove.mode) {
8976 case MENU_MOVE_DUNGEON_ESCAPE:
8977 case MENU_MOVE_FIRST_DUNGEON:
8978 case MENU_MOVE_INTERIOR_OUT:
8979 break;
8980 case MENU_MOVE_WORLD_MAP_DIRECT:
8981 case MENU_MOVE_WORLD_MAP:
8982 SysCur[0] = 328.0f;
8983 SysCur[1] = 164.0f;
8984 break;
8985 }
8986 }
8987
8988 break;
8989 }
8990 case MENU_MOVE_STATE_CLOSE: {
8991 done = ToFromSelect(1);
8992
8993 if (MenuMove.mode == MENU_MOVE_WORLD_MAP_DIRECT) {
8994 done = 1;
8995 }
8996
8997 if (done != 0 && MenuMove.counter > 0x14) {
8998 MenuMove.ready = 0;
8999 ForBackMenu();
9000
9001 switch (MenuMove.mode) {
9002 case MENU_MOVE_WORLD_MAP_DIRECT:
9003 GamePad.AutoRepeatOff();
9004 GamePad.MenuModeOff();
9005 TexManager.DeleteTextureBlock(MenuMove.tex_block);
9006 break;
9007 default:
9008 BattleMenuFlag = BTLMENU_STATE_MAIN;
9009 break;
9010 }
9011
9012 for (int i = 0; i < 10; i++) {
9013 CommonMenuMes3.mes_no[i] = -1;
9014 }
9015
9016#ifdef PAL
9017 for (int i = 0; i < 4; i++) {
9018 CommonMenuMes1.mes_no[i] = -1;
9019
9020 if (i >= 0 && i < 10) {
9021 CommonMenuMes1.line_pos[i].x = -1;
9022 CommonMenuMes1.line_pos[i].y = -1;
9023 }
9024 }
9025#endif
9026 }
9027
9028 break;
9029 }
9030 case MENU_MOVE_STATE_ZOOM_IN:
9031 mapo[0] += mapmovev[0];
9032 mapo[1] += mapmovev[1];
9033 mapo[2] += mapmovev[2];
9034
9035 if (MenuMove.counter > 0xF) {
9036 MenuMove.state = MENU_MOVE_STATE_CONFIRM;
9037 }
9038
9039 break;
9040 case MENU_MOVE_STATE_ZOOM_OUT:
9041 mapo[0] += mapmovev[0];
9042 mapo[1] += mapmovev[1];
9043 mapo[2] += mapmovev[2];
9044
9045 if (MenuMove.counter > 0xF) {
9046 mapo[0] = 0.0f;
9047 mapo[1] = 0.0f;
9048 mapo[2] = 0.0f;
9049 MenuMove.state = MENU_MOVE_STATE_SELECT;
9050 }
9051
9052 break;
9053 case MENU_MOVE_STATE_CONFIRM:
9054 switch (MenuMove.cursor) {
9055 case WORLD_PLACE_WISE_OWL_FOREST:
9056 case WORLD_PLACE_FIELD_S04:
9057 case WORLD_PLACE_MUSKA_LACKA:
9058 case WORLD_PLACE_FIELD_S32:
9059 case WORLD_PLACE_SUN_MOON_TEMPLE:
9060 case WORLD_PLACE_FIELD_S13:
9061 case WORLD_PLACE_YELLOW_DROPS:
9062 case WORLD_PLACE_FIELD_S30:
9063 help = 0x13A;
9064 break;
9065 default:
9066 help = 0x139;
9067 break;
9068 }
9069
9070 if (GamePad.Down(PAD_CROSS) != 0) {
9071 MenuMapJumpMode = MenuGrobalMapNoTbl[MenuMove.cursor];
9072
9073 if (MapNo != MenuMapJumpMode) {
9074 stay = 0;
9075 ComMenuSePlay(MENU_SOUND_CONFIRM);
9076 } else if (MenuMove.mode == MENU_MOVE_WORLD_MAP_DIRECT) {
9077 stay = 0;
9078 MenuMapJumpMode = MapNo;
9079 } else {
9080 stay = 1;
9081 ComMenuSePlay(MENU_SOUND_REFUSE);
9082 }
9083 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
9084 MenuMove.state = MENU_MOVE_STATE_ZOOM_OUT;
9085 MenuMove.counter = 0;
9086 mapmovev[0] = -mapmovev[0];
9087 mapmovev[1] = -mapmovev[1];
9088 mapmovev[2] = -mapmovev[2];
9089 }
9090
9091 break;
9092 case MENU_MOVE_STATE_SELECT: {
9093 int old_cursor = MenuMove.cursor;
9094
9095 switch (MenuMove.mode) {
9096 case MENU_MOVE_DUNGEON_ESCAPE:
9097 case MENU_MOVE_FIRST_DUNGEON:
9098 case MENU_MOVE_INTERIOR_OUT:
9099 if (GamePad.Down(PAD_UP | PAD_DOWN) != 0) {
9100 if (MenuMove.cursor != 0) {
9101 MenuMove.cursor = 0;
9102 } else {
9103 MenuMove.cursor = 1;
9104 }
9105 }
9106
9107 if (GamePad.Down(PAD_CROSS) != 0) {
9108 decided = 1;
9109
9110 if (MenuMove.cursor == 0) {
9111 stay = 0;
9112
9113 switch (MenuMove.mode) {
9114 case MENU_MOVE_DUNGEON_ESCAPE:
9115 NowMonstorUnit->GetMonstorNum();
9116
9117 switch (EscapeDungeonMode()) {
9118 case ESCAPE_DNG_POWDER:
9119 BtlMenuStatusPt->LostItem(ITEM_ESCAPE_POWDER);
9120 break;
9121 case ESCAPE_DNG_PAY: {
9122 u16 money;
9123 int half;
9124 CUserStatus *status = (CUserStatus *) BtlMenuStatusPt;
9125 money = status->money;
9126 half = money >> 1;
9127
9128 if (money - half >= 0xFFFF) {
9129 status->money = 0xFFFF;
9130 } else {
9131 status->money += -half;
9132 }
9133
9134 break;
9135 }
9136 }
9137
9138 MenuMapJumpMode = 1;
9139 break;
9140 case MENU_MOVE_FIRST_DUNGEON:
9141 MenuMapJumpMode = 0xC8;
9142 break;
9143 case MENU_MOVE_INTERIOR_OUT:
9144 SetInteriorOutFlag(1);
9145 BtlEffectCt = 0.0f;
9146 MenuMove.state = MENU_MOVE_STATE_INTERIOR_FADE;
9147 MenuMove.counter = 0;
9148 stay = 1;
9149 break;
9150 }
9151
9152 ComMenuSePlay(MENU_SOUND_CONFIRM);
9153 } else {
9154 MenuMove.state = MENU_MOVE_STATE_CLOSE;
9155 BattleMenuFlag = BTLMENU_STATE_MOVE_CLOSE;
9156 ComMenuSePlay(MENU_SOUND_REFUSE);
9157 }
9158 }
9159
9160 switch (MenuMove.mode) {
9161 case MENU_MOVE_DUNGEON_ESCAPE: {
9162 int escape = EscapeDungeonMode();
9163 s16 messages[3] = {0x131, 0x130, 0x12F};
9164 message = messages[escape];
9165 break;
9166 }
9167 case MENU_MOVE_FIRST_DUNGEON:
9168 message = 0x136;
9169 break;
9170 case MENU_MOVE_INTERIOR_OUT:
9171 message = 0x137;
9172 break;
9173 }
9174
9175 break;
9176 case MENU_MOVE_WORLD_MAP:
9177 case MENU_MOVE_WORLD_MAP_DIRECT:
9178 WorldMapMoveKey();
9179
9180#ifdef PAL
9181 // Debug builds mark the first place not yet visited as visited, or its dungeon as entered.
9182 if (DebugMode && GamePad.Down2(PAD_CROSS)) {
9183 for (int i = 0; i <= 15; i++) {
9184 if (GetVisitInfo(i, MenuMove.mode) == 0) {
9185 int map = MenuGrobalMapNoTbl[i];
9186 printf("nowset mapID = %d\n", map);
9187
9188 if (map >= 200) {
9189 map -= 200;
9190 }
9191
9192 switch (i) {
9193 case WORLD_PLACE_NORUNE:
9194 case WORLD_PLACE_MATATAKI:
9195 case WORLD_PLACE_FIELD_S04:
9196 case WORLD_PLACE_QUEENS:
9197 case WORLD_PLACE_MUSKA_LACKA:
9198 case WORLD_PLACE_FIELD_S32:
9199 case WORLD_PLACE_FIELD_S13:
9200 case WORLD_PLACE_YELLOW_DROPS:
9201 case WORLD_PLACE_FIELD_S30:
9202 case WORLD_PLACE_DEMON_SHAFT:
9203 BtlMenuSaveDataPt->VisitMap(map, 1);
9204
9205 if (BtlMenuSaveDataPt->VisitMap(map, 0) == 0) {
9206 printf(" mapID = %d, visitflag=%d\n", map, BtlMenuSaveDataPt->VisitMap(map, 0));
9207 } else {
9208 printf("mapID = %d ,visitflag=%d\n", map, BtlMenuSaveDataPt->VisitMap(map, 0));
9209 }
9210
9211 break;
9212 default:
9213 BtlMenuSaveDataPt->QuestDungeon(map, 1);
9214 break;
9215 }
9216
9217 break;
9218 }
9219 }
9220 }
9221
9222#endif
9223 if (MenuMove.cursor < 0) {
9224 MenuMove.cursor = WORLD_PLACE_FIELD_S04;
9225 }
9226
9227 if (GamePad.Down(PAD_CROSS) != 0) {
9228 decided = 1;
9229 MenuMapJumpMode = MenuGrobalMapNoTbl[MenuMove.cursor];
9230
9231 if (MenuMove.mode != MENU_MOVE_WORLD_MAP_DIRECT && MapNo == MenuMapJumpMode) {
9232 stay = 1;
9233 ComMenuSePlay(MENU_SOUND_REFUSE);
9234 } else {
9235 ComMenuSePlay(MENU_SOUND_CONFIRM);
9236 MenuMove.state = MENU_MOVE_STATE_ZOOM_IN;
9237 float world[4];
9238 float local[4] = {0.0f, 0.0f, 0.0f, 1.0f};
9239 MapMoveCursor->GetWorldPosition(world, local);
9240 mapmovev[0] = -world[0] / 15.0f;
9241 mapmovev[1] = -world[1] / 15.0f;
9242 mapmovev[2] = 2.4f;
9243 }
9244 }
9245
9246 message = 0x138;
9247 break;
9248 }
9249
9250 if (old_cursor != MenuMove.cursor) {
9251 ComMenuSePlay(MENU_SOUND_CURSOR);
9252 }
9253
9254 if (decided == 0 && GamePad.Down(PAD_CIRCLE) != 0) {
9255 switch (MenuMove.mode) {
9256 case MENU_MOVE_DUNGEON_ESCAPE:
9257 MenuMapJumpMode = 0;
9258 break;
9259 case MENU_MOVE_WORLD_MAP_DIRECT:
9260 break;
9261 case MENU_MOVE_WORLD_MAP:
9262 case MENU_MOVE_FIRST_DUNGEON:
9263 MenuMapJumpMode = -1;
9264 break;
9265 case MENU_MOVE_INTERIOR_OUT:
9266 SetInteriorOutFlag(0);
9267 break;
9268 }
9269
9270 if (MenuMove.mode != MENU_MOVE_WORLD_MAP_DIRECT) {
9271 MenuMove.state = MENU_MOVE_STATE_CLOSE;
9272
9273 if (MenuMove.mode != MENU_MOVE_WORLD_MAP_DIRECT) {
9274 BattleMenuFlag = BTLMENU_STATE_MOVE_CLOSE;
9275 }
9276 }
9277
9278 ComMenuSePlay(MENU_SOUND_REFUSE);
9279 }
9280
9281 break;
9282 }
9283 case MENU_MOVE_STATE_INTERIOR_FADE:
9284 if (!(BtlEffectCt <= 44.0f)) {
9285 ExitBattleMenu(1);
9286 stay = 0;
9287 }
9288
9289 break;
9290 }
9291
9292 int names[16] = {0, 1, 2, 3, 4, 5, 6, 7, 13, 8, 9, 10, 11, 14, 12, 15};
9293 int name = names[MenuMove.cursor] + 0xA;
9294
9295 if (message == 0x138 && CommonMenuMes3.mes_no[0] != name) {
9296 CommonMenuMes3.mes_no[0] = name;
9297 CommonMenuMes3.mes_made = -1;
9298 }
9299
9300 if ((u32) (help - 0x139) < 2 && CommonMenuMes2.mes_no[0] != name) {
9301 CommonMenuMes2.mes_no[0] = name;
9302 GetMsgLengthMenu(&CommonMenuMes2, name);
9303 help = 0x13A;
9304 CommonMenuMes2.mes_no[0] = name;
9305 CommonMenuMes2.mes_made = -1;
9306 }
9307
9308 if (CommonMenuMes3.mes_made != message) {
9309 CommonMenuMes3.MakeMesWin(message);
9310 }
9311
9312 if (CommonMenuMes2.mes_made != help) {
9313 CommonMenuMes2.MakeMesWin(help);
9314 }
9315
9316 return stay;
9317}
9318
9319void DrawMenuMove() {
9320 int alpha;
9321 int x;
9322 int y;
9323 int size[4];
9324
9325 if (MenuMove.mode == MENU_MOVE_WORLD_MAP_DIRECT) {
9326 MenuWorldTrans(&MenuCamera);
9327 FrameImageDraw(0x40, 0x80);
9328 }
9329
9330 BtlMenuTexBlockEnter();
9331 alpha = 0x80;
9332
9333 switch (MenuMove.state) {
9334 case MENU_MOVE_STATE_OPEN:
9335 alpha = MenuMove.counter * 6;
9336 break;
9337 case MENU_MOVE_STATE_CLOSE:
9338 alpha = 0x80 - MenuMove.counter * 8;
9339 break;
9340 }
9341
9342 if (alpha > 0x80) {
9343 alpha = 0x80;
9344 }
9345
9346 if (alpha < 0) {
9347 alpha = 0;
9348 }
9349
9350 float ease = 4.0f;
9351
9352 switch (MenuMove.mode) {
9353 case MENU_MOVE_DUNGEON_ESCAPE:
9354 case MENU_MOVE_INTERIOR_OUT:
9355 (void) x;
9356 break;
9357 case MENU_MOVE_FIRST_DUNGEON:
9358 (void) x;
9359 break;
9360 }
9361
9362 switch (MenuMove.mode) {
9363 case MENU_MOVE_DUNGEON_ESCAPE: {
9364#ifdef PAL
9365 DrawEscapeItem(0x32, 0x160, alpha);
9366#else
9367 DrawEscapeItem(0x32, 0x140, alpha);
9368#endif
9369 int half = CommonMenuMes3.char_width >> 1;
9370 y = 0x140 - half;
9371 CommonMenuMes3.NeedMesWinWH(CommonMenuMes3.mes_made, size);
9372 CommonMenuMes3.text_x = y - (size[2] >> 1) + 0xA;
9373 CommonMenuMes3.text_y = 0x7E;
9374 CommonMenuMes3.stay_frame = true;
9375
9376 if (MenuMove.state == MENU_MOVE_STATE_CLOSE) {
9377 CommonMenuMes3.stay_frame = false;
9378 }
9379
9380 CommonMenuMes3.edge_alpha = alpha;
9381 MenuTextureReload(BtlMenuReadBlock);
9382 DrawDngYesNoDialog(0x118, 0xDC, alpha);
9383 x = 0xF6;
9384 y = MenuMove.cursor * 0x1C + 0xD2;
9385 break;
9386 }
9387 case MENU_MOVE_INTERIOR_OUT:
9388 case MENU_MOVE_FIRST_DUNGEON: {
9389 int half = CommonMenuMes3.char_width >> 1;
9390 y = 0x140 - half;
9391 CommonMenuMes3.NeedMesWinWH(CommonMenuMes3.mes_made, size);
9392 CommonMenuMes3.text_x = y - (size[2] >> 1) + 0xA;
9393
9394 if (MenuMove.mode == MENU_MOVE_FIRST_DUNGEON && CommonMenuMes3.mes_made > 0 && size[2] >= 0x28 && size[3] < 0xC9) {
9395 CommonMenuMes3.text_y = 0x94;
9396 MenuHelpWinDraw2(CommonMenuMes3.text_x - 0x1A, CommonMenuMes3.text_y - 4, 8.0f + (float) size[2], 2.0f + (float) size[3], alpha, 0, 0, StayTex);
9397 }
9398
9399 if (MenuMove.mode == MENU_MOVE_INTERIOR_OUT && CommonMenuMes3.mes_made > 0 && size[2] >= 0x28 && size[3] < 0xC9) {
9400 CommonMenuMes3.text_y = 0x92;
9401 MenuHelpWinDraw2(CommonMenuMes3.text_x - 0x1A, CommonMenuMes3.text_y - 4, 8.0f + (float) size[2], 2.0f + (float) size[3], alpha, 0, 0, StayTex);
9402 }
9403
9404 CommonMenuMes3.stay_frame = false;
9405 CommonMenuMes3.edge_alpha = alpha;
9406 MenuTextureReload(BtlMenuReadBlock);
9407 DrawDngYesNoDialog(0x118, 0xD8, alpha);
9408 x = 0xF6;
9409 y = MenuMove.cursor * 0x1C + 0xD2;
9410 break;
9411 }
9412 case MENU_MOVE_WORLD_MAP_DIRECT:
9413 case MENU_MOVE_WORLD_MAP: {
9414 WORLD_MAP_POS *next = (WORLD_MAP_POS *) NextWorldPos;
9415
9416 if (next != NULL) {
9417 x = next->x;
9418 y = next->y;
9419 } else {
9420 int place = MapNoTransFunc(MapNo);
9421 s16 pos[15][2] = {
9422 {0x150, 0xB2 },
9423 {0, 0 },
9424 {0x12A, 0xDC },
9425 {0, 0 },
9426 {0x104, 0xB4 },
9427 {0xC4, 0xCE },
9428 {0x90, 0xD6 },
9429 {0xF0, 0x114},
9430 {0x13A, 0x148},
9431 {0x147, 0x13C},
9432 {0x1D2, 0x90 },
9433 {0x1D6, 0xAB },
9434 {0x1B4, 0x90 },
9435 {0x1BB, 0x126},
9436 {0x1C3, 0x112}
9437 };
9438 x = pos[place][0];
9439 y = pos[place][1];
9440 SysCur[0] = (float) x;
9441 SysCur[1] = (float) y;
9442 }
9443
9444 ease = 3.0f;
9445 int map_alpha = 0x80;
9446
9447 switch (MenuMove.state) {
9448 case MENU_MOVE_STATE_CLOSE:
9449 map_alpha = alpha;
9450 break;
9451 }
9452
9453 if (MenuMove.ready != 0 && MenuCharaFrame.frame != NULL) {
9454 DrawWorldMap(map_alpha);
9455 }
9456
9457 break;
9458 }
9459 }
9460
9461 SysCur[0] += ((float) x - SysCur[0]) / ease;
9462 SysCur[1] += ((float) y - SysCur[1]) / ease;
9463 int arrived = true;
9464
9465 switch (MenuMove.mode) {
9466 case MENU_MOVE_WORLD_MAP:
9467 case MENU_MOVE_WORLD_MAP_DIRECT:
9468 if (!((float) abs((int) (SysCur[0] - (float) x)) <= 4.0f) && !((float) abs((int) (SysCur[1] - (float) y)) <= 4.0f)) {
9469 arrived = false;
9470 }
9471
9472 if (MenuMove.state != MENU_MOVE_STATE_CONFIRM || MenuMove.state != MENU_MOVE_STATE_CLOSE) {
9473 CommonMenuMes3.stay_frame = false;
9474 }
9475
9476 break;
9477 }
9478
9479 int waku_x = x + 0x1A;
9480 int waku_y = y - 2;
9481 float width = 1.0f;
9482
9483 switch (MenuMove.mode) {
9484 case MENU_MOVE_DUNGEON_ESCAPE:
9485 case MENU_MOVE_FIRST_DUNGEON:
9486 case MENU_MOVE_INTERIOR_OUT:
9487 if (MenuMove.cursor != 0) {
9488 width = 98.0f;
9489 } else {
9490 width = 98.0f;
9491 }
9492
9493 break;
9494 case MENU_MOVE_WORLD_MAP:
9495 case MENU_MOVE_WORLD_MAP_DIRECT:
9496 GetMenuLangFlag();
9497 width = (float) CommonMenuMes3.GetMesWidth_system(CommonMenuMes3.mes_no[0]);
9498 CommonMenuMes3.text_x = (int) ((double) x - (double) width / 2.0);
9499 CommonMenuMes3.text_y = y - 0x22;
9500 break;
9501 }
9502
9503 x = (int) SysCur[0];
9504 y = (int) SysCur[1];
9505
9506 switch (MenuMove.state) {
9507 case MENU_MOVE_STATE_SELECT:
9508 switch (MenuMove.mode) {
9509 case MENU_MOVE_DUNGEON_ESCAPE:
9510 case MENU_MOVE_FIRST_DUNGEON:
9511 case MENU_MOVE_INTERIOR_OUT:
9512 DrawMenuWaku((float) waku_x, (float) waku_y, (int) width, 0x1A, 0, StayTex, 0x80);
9513 DrawMenuObjectVibe(x, y, 1, 0x40);
9514 break;
9515 case MENU_MOVE_WORLD_MAP:
9516 case MENU_MOVE_WORLD_MAP_DIRECT: {
9517 MenuTextureReload(MenuMove.tex_block);
9518 DrawMapCheck(0x80);
9519#ifdef PAL
9520 CRect_i_ texel(0xE2, 0, 0x1E, 0x20);
9521#else
9522 CRect_i_ texel(0xE0, 0, 0x20, 0x20);
9523#endif
9524 DrawObjectVibe(x + 2, y + 2, MenuMoveTex, texel, 0xA, 0x50);
9525 DrawObjectVibe(x, y, MenuMoveTex, texel, 0x80, 0x80);
9526 CommonMenuMes3.stay_frame = false;
9527 MenuHelpWinDraw2(CommonMenuMes3.text_x - 0x18, CommonMenuMes3.text_y - 0xE, 1.0f + width, 0.0f, 0x80, 0, 0, StayTex);
9528 break;
9529 }
9530 }
9531
9532 break;
9533 case MENU_MOVE_STATE_OPEN:
9534 case MENU_MOVE_STATE_CLOSE:
9535 break;
9536 case MENU_MOVE_STATE_CONFIRM:
9537 MenuHelpWinDraw2(CommonMenuMes3.text_x - 0x18, CommonMenuMes3.text_y - 0xE, 1.0f + width, 0.0f, 0x80, 0, 0, StayTex);
9538 break;
9539 }
9540
9541 MenuTextureReload(CommonMenuMes3.tex_block);
9542
9543 if (arrived != 0 && (MenuMove.state != MENU_MOVE_STATE_CONFIRM || MenuMove.state != MENU_MOVE_STATE_CLOSE)) {
9544 switch (MenuMove.state) {
9545 case MENU_MOVE_STATE_ZOOM_IN:
9546 alpha = 0x80 - MenuMove.counter * 0xA;
9547 break;
9548 case MENU_MOVE_STATE_ZOOM_OUT:
9549 alpha = MenuMove.counter * 6;
9550 break;
9551 }
9552
9553 if (alpha < 0) {
9554 alpha = 0;
9555 }
9556
9557 if (alpha > 0x80) {
9558 alpha = 0x80;
9559 }
9560
9561 CommonMenuMes3.edge_alpha = alpha;
9562 CommonMenuMes3.Step();
9563 CommonMenuMes3.DrawMesWin();
9564 }
9565
9566 if (MenuMove.state == MENU_MOVE_STATE_CONFIRM) {
9567 float win_x;
9568 float win_y;
9569 float win_w;
9570 float win_h;
9571 GetMainMenuRightHelpWinLangOffset(win_x, win_y, win_w, win_h);
9572
9573 if (GetMenuLangFlag() > LANG_JAPANESE) {
9574 win_x -= 12.0f;
9575 win_w = 1.2f + win_w;
9576 }
9577
9578 MenuHelpWinDraw((int) win_x, (int) win_y, win_w, win_h, 0x80);
9579 int text_x;
9580 int text_y;
9581 GetMainMenuRightHelpMsgLangOffset(text_x, text_y);
9582 CommonMenuMes2.text_x = (int) (win_x + (float) text_x);
9583 CommonMenuMes2.text_y = (int) (win_y + (float) text_y);
9584 CommonMenuMes2.Step();
9585 CommonMenuMes2.DrawMesWin();
9586 }
9587
9588 if (MenuMove.mode == MENU_MOVE_WORLD_MAP_DIRECT) {
9589 MenuTextureReload(MenuMove.tex_block);
9590 int title_w = 0xD8;
9591
9592 if (GetMenuLangFlag() > LANG_JAPANESE) {
9593#ifdef PAL
9594 title_w = 0xE0;
9595#else
9596 title_w = 0xDE;
9597#endif
9598 }
9599
9600 DrawMenu2DSprite(MenuMoveTex, CRect_i_(0x3C, 0x28, title_w, 0x28), CRect_i_(0, 0, title_w, 0x28), 0x80);
9601 }
9602
9603 if (MenuMove.state == MENU_MOVE_STATE_INTERIOR_FADE && GetInteriorOutFlag() != 0) {
9604 alpha = MenuMove.counter * 3;
9605
9606 if (alpha > 0x80) {
9607 alpha = 0x80;
9608 }
9609
9610 AllFadeForMenu(alpha);
9611 }
9612
9613 switch (MenuMove.state) {
9614 case MENU_MOVE_STATE_SELECT:
9615 case MENU_MOVE_STATE_CONFIRM:
9616 MenuMove.counter = 0;
9617 break;
9618 default:
9619 MenuMove.counter++;
9620 break;
9621 }
9622}
9623
9624void DrawEscapeItem(int x, int y, int alpha) {
9625#ifdef PAL
9626 float widths[7] = {8.6f, 9.0f, 9.0f, 11.0f, 9.0f, 9.0f, 9.0f};
9627#else
9628 float widths[7] = {8.6f, 9.0f, 9.0f, 9.0f, 9.0f, 9.0f, 9.0f};
9629#endif
9630 int u;
9631 int v;
9632
9633 float height = 1.0f;
9634 MenuHelpWinDraw(x, y, widths[BtlMenuNowLang], height, alpha);
9635 int row_y = y + 0x10;
9636 MenuTextureReload(BtlMenuReadBlock);
9637
9638 if (PerBoardTex == NULL) {
9639 PerBoardTex = TexManager.GetTexture("perbrd", -1);
9640 }
9641
9642 int money = ((CUserStatus *) BtlMenuStatusPt)->money;
9643 CommonMoneyBoardDraw(x, y - 0x1E, money, alpha);
9644#ifdef PAL
9645 s8 shift[7] = {0, 0, 0, 34, 0, 0, 0};
9646#endif
9647 int count = GetNowItemNum(ITEM_ESCAPE_POWDER, MenuItemPackPt);
9648 CTexture *icon = RetCTex(0xAF, u, v);
9649 DrawMenu2DSprite(icon, CRect_i_(x + 0x14, row_y, 0x20, 0x20), CRect_i_(u, v, 0x20, 0x20), alpha);
9650#ifdef PAL
9651 DrawMenu2DSprite(BtStatus, CRect_i_(x + 0x86 + shift[BtlMenuNowLang], row_y + 8, 0x10, 0x10), CRect_i_(0x60, 0x58, 0x10, 0x10), alpha);
9652 int number_x = x + 0xA2 + shift[BtlMenuNowLang];
9653#else
9654 DrawMenu2DSprite(BtStatus, CRect_i_(x + 0x86, row_y + 8, 0x10, 0x10), CRect_i_(0x60, 0x58, 0x10, 0x10), alpha);
9655 int number_x = x + 0xA2;
9656#endif
9657 number_x += GetNumberKeta(count) * 6;
9658 DrawMenuNumber(count, number_x, row_y + 8, StayTex, NumberSprite[1], 2, alpha);
9659 s16 messages[7] = {0x138, 0x1A8, 0x1A8, 0x1A8, 0x1A8, 0x1A8, 0x1A8};
9660
9661 if (CommonMenuMes1.mes_made != messages[BtlMenuNowLang]) {
9662 CommonMenuMes1.mes_no[0] = 0x113;
9663 CommonMenuMes1.MakeMesWin(messages[BtlMenuNowLang]);
9664 }
9665
9666 if (BtlMenuNowLang > LANG_JAPANESE) {
9667 row_y += 0x10;
9668 CommonMenuMes1.line_pos[0].x = x + 0x38;
9669 CommonMenuMes1.line_pos[0].y = row_y - 0x14;
9670 CommonMenuMes1.line_pos[1].x = x + 0x3C;
9671 CommonMenuMes1.line_pos[1].y = row_y;
9672 }
9673
9674 MenuTextureReload(CommonMenuMes1.tex_block);
9675 CommonMenuMes1.edge_alpha = alpha;
9676 CommonMenuMes1.stay_frame = false;
9677 DrawMenuClsMes(&CommonMenuMes1, x + 0x38, row_y - 0x10);
9678}
9679
9683inline void AddWorldMapFileName(char *path, int region) {
9684 char *files[6] = {"matatagi.pac", "queen.pac", "musuka.pac", "moon.pac", "dark.pac", "lastdng.pac"};
9685
9686 strcat(path, files[region]);
9687}
9688
9689static void StartLoadWorldMap(int region, u_long128 *buffer) {
9690 char path[64];
9691 int size;
9692
9693 if (region < 0 || region > 5) {
9694 return;
9695 }
9696
9697 GetPathReadDifferntLang(path);
9698 strcat(path, "map/");
9699 AddWorldMapFileName(path, region);
9700 StartReadBG();
9701 LoadFileBG(path, buffer, &size);
9702}
9703
9704int LoadWorldMap() {
9705 if (ReadBGSync() == 0) {
9706 BG_READ_INFO *file = GetReadBGFile(0);
9707 char img_format[32] = "w_map_1%d.img";
9708 char cfg_format[32] = "w_map1%d.cfg";
9709 char img[32];
9710 char cfg[32];
9711 sprintf(img, img_format, MenuMove.load_map + 1);
9712 sprintf(cfg, cfg_format, MenuMove.load_map + 1);
9713 LOADTEXTURE_INFO2 textures[5] = {
9714 {"#frame_imagemove#640#" SCREEN_HEIGHT_STR "#4", 0, 0},
9715 {NULL, 0, 0},
9716 {NULL, 0, 0},
9717 {NULL, 0, 0},
9718 {NULL, 0, 0}
9719 };
9720 textures[0].block_no = MenuMove.tex_block;
9721 textures[1].block_no = MenuMove.tex_block;
9722 textures[2].block_no = MenuMove.tex_block;
9723 textures[3].block_no = MenuMove.tex_block;
9724 textures[1].name = (char *) GetPackFile((u_int *) file->buffer, "w_map_02.img", NULL);
9725 textures[2].name = (char *) GetPackFile((u_int *) file->buffer, img, NULL);
9726 textures[3].name = (char *) GetPackFile((u_int *) file->buffer, "menumove.img", NULL);
9727 TexManager.DeleteTextureBlock(MenuMove.tex_block);
9728 int blocks[2] = {0, -1};
9729 blocks[0] = MenuMove.tex_block;
9730 MenuTextureDelete(blocks);
9731 TexManager.CleanUpTextureList();
9732 BtlMenuTexBlockEnter();
9733 TexManager.LoadTextureBlockEX(-1, textures);
9734 MenuMoveTex = TexManager.GetTexture("menumove", -1);
9735
9736 if (MenuMove.mode == MENU_MOVE_WORLD_MAP_DIRECT) {
9737 InitMenuMesSet(MENU_MES_SET_WORLD_MAP, (short *) GetPackFile((u_int *) file->buffer, "allmenu.mes", NULL));
9738 }
9739
9740 u_long128 *model = file->buffer + ((((file->size >> 6) + 1) << 6) >> 4);
9741 MenuCharaFrame.Initialize();
9742 MenuExCashBuffer.base = (u_char *) model;
9743 MenuExCashBuffer.limit = 0xCF80;
9744 MenuExCashBuffer.used = 0;
9745 MenuCharaFrame.LoadPackData((u_int *) file->buffer, cfg, &MenuExCashBuffer, &MenuExCashBuffer, NULL);
9746 mapo[2] = 0.0f;
9747 mapo[1] = 0.0f;
9748 mapo[0] = 0.0f;
9749 mapo[3] = 1.0f;
9750 MenuCharaFrame.SetPosition(mapo);
9751 MenuCharaFrame.motion_no = 0;
9752 MenuCharaFrame.motion_flags = 2;
9753 MenuCharaFrame.motion_speed = -1.0f;
9754 MapMoveCursor = MenuCharaFrame.frame->SearchFrame(TownOrDngPos[MenuMove.cursor].frame);
9755 return 1;
9756 }
9757
9758 return 0;
9759}
9760
9768static void LocalDrawWorldMap() {
9769 MenuCharaFrame.SetScale(2.2f, 2.2f, 2.2f);
9770 MenuCharaFrame.SetPosition(mapo);
9771 MenuCharaFrame.Step();
9772 MenuCharaFrame.Draw();
9773}
9774
9782static void DrawWorldMap(int alpha) {
9783 MenuTextureReload(MenuMove.tex_block);
9784 MenuPolygonDraw(alpha, LocalDrawWorldMap);
9785}
9786
9787void MenuDataSwap(MAP_JUMP_COMPARE *first, MAP_JUMP_COMPARE *second) {
9788 MAP_JUMP_COMPARE saved;
9789
9790 memcpy(&saved, first, sizeof(MAP_JUMP_COMPARE));
9791 memcpy(first, second, sizeof(MAP_JUMP_COMPARE));
9792 memcpy(second, &saved, sizeof(MAP_JUMP_COMPARE));
9793}
9794
9795int GetNearWorldPos(int direction, int *position) {
9796 if (direction == 0) {
9797 return -1;
9798 }
9799
9800 int up;
9801 int down;
9802 int right;
9803 int left;
9804 WORLD_MAP_POS *from = &TownOrDngPos[MenuMove.cursor];
9805 float dx = 0.0f;
9806 float dy = dx;
9807 up = direction & 1;
9808
9809 if (up) {
9810 dy -= 1.0f;
9811 }
9812
9813 down = direction & 2;
9814
9815 if (down) {
9816 dy += 1.0f;
9817 }
9818
9819 right = direction & 8;
9820
9821 if (right) {
9822 dx += 1.0f;
9823 }
9824
9825 left = direction & 4;
9826
9827 if (left) {
9828 dx -= 1.0f;
9829 }
9830
9831 float length = sqrt(dx * dx + dy * dy);
9832
9833 if (length != 0.0f) {
9834 dx /= length;
9835 }
9836
9837 if (length != 0.0f) {
9838 dy /= length;
9839 }
9840
9841 MAP_JUMP_COMPARE places[16];
9842
9843 for (int i = 0; i < 16; i++) {
9844 MAP_JUMP_COMPARE *place = &places[i];
9845 place->index = i;
9846 WORLD_MAP_POS *pos = &TownOrDngPos[i];
9847
9848 if (pos->visited <= 0 || i == MenuMove.cursor) {
9849 place->reachable = 0;
9850 } else {
9851 place->reachable = 1;
9852 }
9853
9854 place->dx = pos->x - from->x;
9855 place->dy = pos->y - from->y;
9856 place->distance_sq = place->dx * place->dx + place->dy * place->dy;
9857 float distance = sqrt(place->distance_sq);
9858 float nx = place->dx;
9859 float ny = place->dy;
9860
9861 if (distance != 0.0f) {
9862 nx /= distance;
9863 ny /= distance;
9864 }
9865
9866 place->alignment = nx * dx + ny * dy;
9867 }
9868
9869 for (int i = 0; i < 16;) {
9870 int swapped = 0;
9871 MAP_JUMP_COMPARE *place = &places[i];
9872
9873 for (int j = i + 1; j < 16; j++) {
9874 MAP_JUMP_COMPARE *other = &places[j];
9875
9876 if (place->alignment < other->alignment) {
9877 MenuDataSwap(place, other);
9878 swapped = 1;
9879 break;
9880 }
9881 }
9882
9883 if (!swapped) {
9884 i++;
9885 }
9886 }
9887
9888 int nearest = -1;
9889 int nearest_sq = 600000;
9890
9891 for (int i = 0; i < 16; i++) {
9892 MAP_JUMP_COMPARE *place = &places[i];
9893
9894 if (place->reachable > 0 && (!up || place->dy < 0) && (!down || place->dy > 0) && (!right || place->dx > 0) && (!left || place->dx < 0) && place->distance_sq < nearest_sq) {
9895 nearest = place->index;
9896 nearest_sq = place->distance_sq;
9897 }
9898 }
9899
9900 return nearest;
9901}
9902
9910static int WorldMapMoveKey() {
9911 int position[2];
9912
9913 position[0] = SysCur[0];
9914 position[1] = SysCur[1];
9915 int direction = 0;
9916
9917 if (GamePad.Down(PAD_UP) != 0) {
9918 direction |= 1;
9919 }
9920
9921 if (GamePad.Down(PAD_DOWN) != 0) {
9922 direction |= 2;
9923 }
9924
9925 if (GamePad.Down(PAD_RIGHT) != 0) {
9926 direction |= 8;
9927 }
9928
9929 if (GamePad.Down(PAD_LEFT) != 0) {
9930 direction |= 4;
9931 }
9932
9933 if (direction > 0) {
9934 direction = GetNearWorldPos(direction, position);
9935
9936 if (direction < 16 && direction >= 0) {
9937 NextWorldPos = TownOrDngPos[direction].frame;
9938 MenuMove.cursor = direction;
9939 MapMoveCursor = MenuCharaFrame.frame->SearchFrame(TownOrDngPos[MenuMove.cursor].frame);
9940 }
9941 }
9942
9943 return 1;
9944}
9945
9953void DrawMapCheck(int alpha) {
9954#ifndef PAL
9955 s16 offset[16][2] = {0};
9956#endif
9957 CRect_i_ dst(0, 0, 0x10, 0xF);
9958 CRect_i_ src(0, 0x68, 0x15, 0x15);
9959
9960 for (int i = 0; i < 16; i++) {
9961 WORLD_MAP_POS *place = &TownOrDngPos[i];
9962
9963 if (place->frame != NULL && place->visited > 0) {
9964 CFrame *frame = MenuCharaFrame.frame->SearchFrame(place->frame);
9965
9966 if (frame != NULL) {
9967 int pos[2];
9968
9969 Get3DPosTo2DPos(frame, pos);
9970#ifdef PAL
9971 dst.x = pos[0];
9972 dst.y = pos[1];
9973#else
9974 dst.x = pos[0] + offset[i][0];
9975 dst.y = pos[1] + offset[i][1];
9976#endif
9977 src.x = 0;
9978
9979 if (MenuMove.start_place == i) {
9980 src.x += 0x14;
9981 }
9982
9983 DrawMenu2DSprite(MenuMoveTex, dst, src, 0x80);
9984 }
9985 }
9986 }
9987}
9988
9996static int GetVisitInfo(int place, int menu_mode) {
9997 int visits;
9998 int dungeon;
9999 int map_no = MenuGrobalMapNoTbl[place];
10000
10001 if (map_no >= 200) {
10002 map_no -= 200;
10003 }
10004
10005 switch (place) {
10006 case WORLD_PLACE_NORUNE:
10007 case WORLD_PLACE_MATATAKI:
10008 case WORLD_PLACE_FIELD_S04:
10009 case WORLD_PLACE_QUEENS:
10010 case WORLD_PLACE_MUSKA_LACKA:
10011 case WORLD_PLACE_FIELD_S32:
10012 case WORLD_PLACE_FIELD_S13:
10013 case WORLD_PLACE_YELLOW_DROPS:
10014 case WORLD_PLACE_FIELD_S30:
10015 case WORLD_PLACE_DEMON_SHAFT:
10016 dungeon = 0;
10017 break;
10018 default:
10019 dungeon = 1;
10020 break;
10021 }
10022
10023 if (!dungeon) {
10024 visits = BtlMenuSaveDataPt->VisitMap(map_no, 0);
10025
10026 switch (NowGetGameFlagForBtlMenu(menu_mode)) {
10027 case MENU_MOVE_WORLD_MAP:
10028 case MENU_MOVE_WORLD_MAP_DIRECT:
10029 if (map_no == 1) {
10030 visits = 1;
10031 }
10032
10033 break;
10034 }
10035 } else {
10036 visits = BtlMenuSaveDataPt->QuestDungeon(map_no, 0);
10037 }
10038
10039 return visits;
10040}
10041
10049static int IsLoadMapNo() {
10050 int region = -1;
10051 s8 map_region[80] = {
10052 0,
10053 0,
10054 1,
10055 2,
10056 3,
10057 0,
10058 0,
10059 0,
10060 0,
10061 0,
10062 0,
10063 0,
10064 0,
10065 0,
10066 0,
10067 0,
10068 0,
10069 0,
10070 0,
10071 1,
10072 1,
10073 3,
10074 2,
10075 3,
10076 0,
10077 0,
10078 0,
10079 2,
10080 0,
10081 3,
10082 3,
10083 3,
10084 3,
10085 0,
10086 2,
10087 1,
10088 2,
10089 3,
10090 0,
10091 1,
10092 4,
10093 3,
10094 2,
10095 1,
10096 1,
10097 1,
10098 0,
10099 0,
10100 0,
10101 0,
10102 0,
10103 0,
10104 0,
10105 0,
10106 0,
10107 0,
10108 0,
10109 0,
10110 0,
10111 0,
10112 5,
10113 5,
10114 };
10115
10116 for (int map_no = 0; map_no < 80; map_no++) {
10117 if (BtlMenuSaveDataPt->VisitMap(map_no, 0) && map_region[map_no] > region) {
10118 region = map_region[map_no];
10119 }
10120 }
10121
10122 s8 dungeon_region[6] = {0, 1, 2, 3, 4, 5};
10123
10124 for (int dungeon = 1; dungeon <= 5; dungeon++) {
10125 if (BtlMenuSaveDataPt->QuestDungeon(dungeon, 0) && dungeon_region[dungeon - 1] > region) {
10126 region = dungeon_region[dungeon - 1];
10127 }
10128 }
10129
10130 return region;
10131}
10132
10140static int MapNoTransFunc(int map_no) {
10141 int place;
10142
10143 if (map_no < 10) {
10144 s16 towns[5] = {WORLD_PLACE_NORUNE, WORLD_PLACE_MATATAKI, WORLD_PLACE_QUEENS, WORLD_PLACE_MUSKA_LACKA, WORLD_PLACE_YELLOW_DROPS};
10145 place = towns[map_no];
10146 }
10147
10148 if (map_no >= 11 && map_no < 200) {
10149 char fields[69] = {
10150 WORLD_PLACE_MATATAKI,
10151 WORLD_PLACE_MATATAKI,
10152 WORLD_PLACE_MATATAKI,
10153 WORLD_PLACE_FIELD_S04,
10154 WORLD_PLACE_FIELD_S04,
10155 WORLD_PLACE_FIELD_S04,
10156 WORLD_PLACE_FIELD_S04,
10157 WORLD_PLACE_FIELD_S04,
10158 WORLD_PLACE_QUEENS,
10159 WORLD_PLACE_QUEENS,
10160 WORLD_PLACE_FIELD_S13,
10161 WORLD_PLACE_FIELD_S32,
10162 WORLD_PLACE_FIELD_S13,
10163 WORLD_PLACE_FIELD_S30,
10164 WORLD_PLACE_FIELD_S30,
10165 WORLD_PLACE_GALLERY_OF_TIME,
10166 WORLD_PLACE_FIELD_S32,
10167 WORLD_PLACE_FIELD_S04,
10168 WORLD_PLACE_FIELD_S13,
10169 WORLD_PLACE_FIELD_S13,
10170 WORLD_PLACE_FIELD_S13,
10171 WORLD_PLACE_FIELD_S13,
10172 WORLD_PLACE_MATATAKI,
10173 WORLD_PLACE_SUN_MOON_TEMPLE,
10174 WORLD_PLACE_SHIPWRECK,
10175 WORLD_PLACE_FIELD_S32,
10176 WORLD_PLACE_MOON_SEA,
10177 WORLD_PLACE_FIELD_S30,
10178 WORLD_PLACE_SHIPWRECK,
10179 WORLD_PLACE_FIELD_S30,
10180 WORLD_PLACE_FIELD_S30,
10181 WORLD_PLACE_FIELD_S32,
10182 WORLD_PLACE_QUEENS,
10183 WORLD_PLACE_QUEENS,
10184 WORLD_PLACE_QUEENS,
10185 WORLD_PLACE_NORUNE,
10186 WORLD_PLACE_FIELD_S30,
10187 WORLD_PLACE_FIELD_S30,
10188 WORLD_PLACE_FIELD_S30,
10189 WORLD_PLACE_FIELD_S30,
10190 WORLD_PLACE_FIELD_S30,
10191 WORLD_PLACE_NORUNE,
10192 WORLD_PLACE_NORUNE,
10193 WORLD_PLACE_NORUNE,
10194 WORLD_PLACE_NORUNE,
10195 WORLD_PLACE_NORUNE,
10196 WORLD_PLACE_NORUNE,
10197 WORLD_PLACE_NORUNE,
10198 WORLD_PLACE_NORUNE,
10199 WORLD_PLACE_DEMON_SHAFT,
10200 WORLD_PLACE_DEMON_SHAFT,
10201 };
10202 place = fields[map_no - 11];
10203 }
10204
10205 if (map_no >= 200) {
10206 s8 dungeons[6] = {WORLD_PLACE_DIVINE_BEAST_CAVE, WORLD_PLACE_WISE_OWL_FOREST, WORLD_PLACE_SHIPWRECK, WORLD_PLACE_SUN_MOON_TEMPLE, WORLD_PLACE_MOON_SEA, WORLD_PLACE_GALLERY_OF_TIME};
10207 map_no -= 200;
10208 place = dungeons[map_no];
10209 }
10210
10211 return place;
10212}
10213
10221static void BattleMenuOptionKey() {
10222 int transition_done = 0;
10223
10224 switch (BtlEffectFlag) {
10225 case BTLEFFECT_PAGE_OPEN:
10226 transition_done = ToFromSelect(0);
10227
10228 if (transition_done != 0) {
10229 BtlEffectFlag = BTLEFFECT_NONE;
10230 BtlEffectCt = 0.0f;
10231 }
10232
10233 break;
10234 case BTLEFFECT_PAGE_CLOSE:
10235 transition_done = ToFromSelect(1);
10236 break;
10237 }
10238
10239 if (BtlEffectFlag != BTLEFFECT_NONE) {
10240 BtlEffectCt += 1.0f;
10241 } else {
10242 BtlEffectCt = 0.0f;
10243 }
10244
10245 int closed = MenuOptionKey();
10246
10247 if (OptionMenuFadeOutStart() != 0) {
10248 BtlEffectFlag = BTLEFFECT_PAGE_CLOSE;
10249
10250 if (transition_done != 0 && closed != 0) {
10251 MenuSelect[0] = BTLMENU_PAGE_OPTION;
10252 BattleMenuFlag = BTLMENU_STATE_OPTION_CLOSE;
10253 ForBackMenu();
10254 BattleMenuFlag = BTLMENU_STATE_MAIN;
10255 }
10256 }
10257}
10258
10266static void BattleMenuSaveKey() {
10267 int transition_done = 0;
10268
10269 switch (BtlEffectFlag) {
10270 case BTLEFFECT_PAGE_OPEN:
10271 transition_done = ToFromSelect(0);
10272
10273 if (transition_done != 0) {
10274 BtlEffectFlag = BTLEFFECT_NONE;
10275 BtlEffectCt = 0.0f;
10276 }
10277
10278 break;
10279 case BTLEFFECT_PAGE_CLOSE:
10280 transition_done = ToFromSelect(1);
10281 break;
10282 }
10283
10284 if (BtlEffectFlag != BTLEFFECT_NONE) {
10285 BtlEffectCt += 1.0f;
10286 } else {
10287 BtlEffectCt = 0.0f;
10288 }
10289
10290 MenuSaveKey();
10291
10292 if (SaveMenuEffectFadeOut() != 0) {
10293 BtlEffectFlag = BTLEFFECT_PAGE_CLOSE;
10294
10295 if (transition_done != 0) {
10296 MenuSelect[0] = BTLMENU_PAGE_SAVE;
10297 // The previous page's close state, so ForBackMenu leaves MenuSelect[0] one page low.
10298 BattleMenuFlag = BTLMENU_STATE_OPTION_CLOSE;
10299 ForBackMenu();
10300 BattleMenuFlag = BTLMENU_STATE_MAIN;
10301 }
10302 }
10303}
10304
10305void BattleManualInit(int *result, u_long128 *load_buffer) {
10306 InitMenuManual(result, load_buffer);
10307}
10308
10309int BattleManualKey() {
10310 int transition_done = 0;
10311
10312 switch (BtlEffectFlag) {
10313 case BTLEFFECT_PAGE_OPEN:
10314 transition_done = ToFromSelect(0);
10315
10316 if (transition_done != 0) {
10317 BtlEffectFlag = BTLEFFECT_NONE;
10318 BtlEffectCt = 0.0f;
10319 }
10320
10321 break;
10322 case BTLEFFECT_PAGE_CLOSE:
10323 transition_done = ToFromSelect(1);
10324 break;
10325 }
10326
10327 if (BtlEffectFlag != BTLEFFECT_NONE) {
10328 BtlEffectCt += 1.0f;
10329 } else {
10330 BtlEffectCt = 0.0f;
10331 }
10332
10333 MenuManualKey();
10334
10335 if (GetNowManualMenuMode() == MANUAL_MODE_CLOSING) {
10336 BtlEffectFlag = BTLEFFECT_PAGE_CLOSE;
10337
10338 if (transition_done != 0) {
10339 MenuSelect[0] = BTLMENU_PAGE_MANUAL;
10340 // The previous page's close state, so ForBackMenu leaves MenuSelect[0] one page low.
10341 BattleMenuFlag = BTLMENU_STATE_SAVE_CLOSE;
10342 ForBackMenu();
10343 BattleMenuFlag = BTLMENU_STATE_MAIN;
10344 }
10345 }
10346
10347 return 0;
10348}
10349
10350static void BattleManualDraw() {
10351 MenuManualDraw();
10352}
10353
10361static void DrawStatusNumberNowAndMax(int *values, int x, int y, int color, int alpha) {
10362 RECT digits = NumberSprite[0];
10363
10364 if (values[0] < 0.3f * values[1]) {
10365 digits.y += 12;
10366 }
10367
10368 int end = DrawMenuNumber(values[1], x, y, StayTex, digits, color, alpha);
10369 DrawMenu2DSprite(StayTex, CRect_i_(end - 11, y, 12, 12), CRect_i_(0x78, digits.y, 12, 12), alpha);
10370 DrawMenuNumber(values[0], end - 11, y, StayTex, digits, color, alpha);
10371}
10372
10373void DrawWepHole(int x, int y, WEAPON_HAVE *weapon, int selected, int alpha) {
10374 if (x < 10 || x > 620) {
10375 return;
10376 }
10377
10378 if (weapon == NULL) {
10379 return;
10380 }
10381
10382 WEAPON_DATA *data = GetWeaponData(weapon->item_no);
10383 u8 colors[3][3] = {
10384 {0x80, 0x80, 0x80},
10385 {0x28, 0x28, 0xA0},
10386 {0xFF, 0xE8, 0x02},
10387 };
10388 x += 10.0f;
10389
10390 for (int i = 0; i < 6; i++) {
10391 if (data->hole[i] - 1 < 0) {
10392 return;
10393 }
10394
10395 if (weapon->attach_kind[i] == 3) {
10396 float width = 26.0f;
10397 float height = 12.0f;
10398 DrawMenu2DSprite(WepStatus, CRect_i_(x + 8, y + 16, width, height), CRect_i_(0xD4, 0x134, 0x1A, 0xD), alpha);
10399 }
10400
10401 int src_y = 0xE0;
10402 int filled = 0;
10403
10404 if (weapon->attach[i].item_no > 0) {
10405 src_y += 0x2A;
10406 filled = 1;
10407 }
10408
10409 CRect_i_ src(0xD4, src_y, 0x2A, 0x2A);
10410 DrawMenu2DSprite(WepStatus, CRect_i_(x + 1, y + 2, 0x2A, 0x29), src, 0, 0, 0, alpha * 80 >> 7);
10411 u8 *color;
10412
10413 if (data->hole[i] == 2) {
10414 color = colors[1];
10415
10416 if (filled) {
10417 color = colors[2];
10418 }
10419 } else {
10420 color = colors[0];
10421 }
10422
10423 DrawMenu2DSprite(WepStatus, CRect_i_(x, y + 1, 0x2A, 0x29), src, color[0], color[1], color[2], alpha);
10424 x += 0x2A;
10425 }
10426}
10427
10429 message = &EastKingMsgCls;
10430}
10431
10433 draw_x = 366;
10434 draw_y = 166;
10435 mode = MENU_CLSMES_OFF;
10436 option_flags = 0;
10437 option_count = 0;
10438 option_start = 0;
10439}
10440
10441void MenuClsMes::SetBuffInfo(short *buffer) {
10442 ClsMes *mes = message;
10443
10444 mes->text_columns = MES_WIN_COLUMNS;
10445 mes->text_rows = 10;
10446 mes->text_len = 0;
10447 mes->text_width = 0;
10448 mes->text_height = 0;
10449 mes->fade = 0.0f;
10450 mes->fade_in = true;
10451 mes->text_rate = mes->text_rate_set;
10452 mes->waiting = false;
10453 mes->text_at = 0.0f;
10454 mes->text_no = 0;
10455 mes->text_from = 0;
10456 mes->page_from = 0;
10457 mes->InitMesWinTbl();
10458 mes->clut_now = mes->clut_default;
10459 mes->wait = 0;
10460 mes->blink = 0;
10461 mes->auto_page_wait = 0;
10462 mes->mes_made = -1;
10463 mes->edge_alpha = 0x80;
10464
10465 for (int i = 0; i < 10; i++) {
10466 mes->mes_no[i] = -1;
10467 }
10468
10469 for (int i = 0; i < 8; i++) {
10470 mes->values[i] = 0;
10471 }
10472
10473 mes->value = 0;
10474 mes->value_signed = false;
10475 mes->value_show = true;
10476 mes->value_narrow = false;
10477 mes->space_width = -1;
10478 mes->space_area = -1;
10479 mes->cursor_row = -1;
10480 mes->cursor_y = 0;
10481 mes->cursor_lit = false;
10482
10483 for (int i = 0; i < 10; i++) {
10484 mes->line_pos[i].x = -1;
10485 mes->line_pos[i].y = -1;
10486 }
10487
10489 message->SetBuff_system(SystemMes);
10490 message->SetBuff(buffer);
10491 message->tex_block = 0x1A;
10492 ClsMes *window = message;
10493 window->auto_pos = MES_POS_NONE;
10494 message->Preset(MES_PRESET_SYSTEM);
10496 message->style = MES_EDGE_BLACK;
10497 message->rows = 9;
10498 message->stay_frame = false;
10499 message->char_width = GetMenuCommonFontW(BtlMenuNowLang, -1);
10500 message->value_show = false;
10501 message->unk_02C = 0x100;
10502 message->init_030 = 0x100;
10503 InitData();
10504}
10505
10507 weapon = selected_weapon;
10508 option_flags = 1;
10509 option_count = 0;
10510
10511 if (selected_weapon != NULL) {
10512 option_flags = selected_weapon->flags;
10513
10514 for (int slot = 0; slot < 6; slot++) {
10515 ATTACH_LIST *attachment = &weapon->attach[slot];
10516 s16 attachment_flags = attachment->sphere_flags;
10517
10518 if (attachment_flags != 0 && attachment_flags != 1) {
10519 option_flags |= attachment_flags;
10520 }
10521 }
10522
10523 option_flags = CheckWeaponOptionStatus(option_flags);
10524 option_count = 0;
10525 int clear_slot;
10526 int changed = 0;
10527
10528 for (int bit = 1; bit <= 13; bit++) {
10529 if (option_flags & (1 << bit)) {
10530 int message_no = bit + 69;
10531 ClsMes *window = message;
10532 int index = option_count;
10533
10534 if (message_no != window->mes_no[index]) {
10535 changed = 1;
10536 }
10537
10538 window->mes_no[index] = message_no;
10539 option_count++;
10540 }
10541 }
10542
10543 for (clear_slot = option_count; clear_slot < 10; clear_slot++) {
10544 ClsMes *window = message;
10545 window->mes_no[clear_slot] = 0;
10546 }
10547
10548 if (changed != 0) {
10549 message->mes_made = -1;
10550 message->MakeMesWin(422);
10551 }
10552 }
10553}
10554
10556 if (message != NULL) {
10557 switch (mode) {
10558 case MENU_CLSMES_OFF:
10559 break;
10560 case MENU_CLSMES_OPTIONS:
10561 case MENU_CLSMES_UNK_2:
10562 NowWeaponStatus(GetNowSelectWeapon());
10563 message->Step();
10564 break;
10565 }
10566 }
10567}
10568
10572static inline int MesLineX(int x, int len) {
10573 return x - len * 5;
10574}
10575
10576void MenuClsMes::Draw1(int x, int y, int draw_alpha) {
10577 if (message != NULL && weapon != NULL) {
10578 int row_y = y;
10579 int option;
10580
10581 switch (mode) {
10582 case MENU_CLSMES_OFF:
10583 break;
10584 case MENU_CLSMES_OPTIONS:
10585 case MENU_CLSMES_UNK_2:
10586 if (option_flags == 0 || option_flags == 1) {
10587 return;
10588 }
10589
10590 row_y -= option_count * 10;
10591 DrawMenu2DSprite(PerBoardTex, CRect_i_(x + 0x1E, row_y - 0x17, 0x52, 0x17), CRect_i_(0x80, 0x68, 0x52, 0x18), alpha);
10592 DrawMenu2DSprite(PerBoardTex, CRect_i_(x - 0x24, y - 10, 0x20, 0x20), CRect_i_(0x80, 0x80, 0x20, 0x20), alpha);
10593 CRect_i_ left(0x20, 0x80, 0x20, 0x18);
10594 CRect_i_ middle(0x40, 0x80, 0x14, 0x18);
10595 CRect_i_ right(0x78, 0x80, 0x8, 0x18);
10596 CRect_i_ icon_src(0xEC, 0x50, 0x14, 0x14);
10597 CTexture *face = TexManager.GetTexture("charaface", -1);
10598
10599 for (option = 1; option <= 13; option++) {
10600 if (option == 8) {
10601 icon_src.x -= icon_src.width;
10602 }
10603
10604 if (option_flags & (1 << option)) {
10605 if (IsWeaponOptionGoodOrBad(option)) {
10606 left.y = middle.y = right.y = 0x80;
10607 } else {
10608 left.y = middle.y = right.y = 0x68;
10609 }
10610
10611 int icon = option;
10612
10613 if (option > 7) {
10614 icon = option - 7;
10615 }
10616
10617 if (option == 8 && icon == 1) {
10618 icon++;
10619 }
10620
10621 if (option == 9 && icon == 2) {
10622 icon--;
10623 }
10624
10625 icon_src.y = icon_src.height * (icon - 1) + 0x50;
10626 DrawMenu2DSprite(PerBoardTex, CRect_i_(x, row_y, left.width, left.height), left, alpha);
10627 DrawMenu2DSprite(PerBoardTex, CRect_i_(x + left.width, row_y, 100, middle.height), middle, alpha);
10628 DrawMenu2DSprite(PerBoardTex, CRect_i_(x + left.width + 100, row_y, right.width, right.height), right, alpha);
10629 DrawMenu2DSprite(face, CRect_i_(x + 2, row_y + 2, 0x14, 0x15), icon_src, alpha);
10630 row_y += left.height;
10631 }
10632 }
10633
10634 MenuTextureReload(message->tex_block);
10635 x = (int) (x + 0xB);
10636 row_y = y - option_count * 10;
10637
10638 for (option = 0; option < option_count; option++, row_y += left.height) {
10639 SetLinePos(message, option, MesLineX(x + 0x11, message->GetMesLen_system(message->mes_no[option])), row_y);
10640 }
10641
10644 break;
10645 }
10646 }
10647}
void SetRef(CFrame *parent, float x, float y, float z)
Definition camera.cpp:124
void SetPos(CFrame *parent, float x, float y, float z)
Definition camera.cpp:103
void SetMotion(int no, int mode, float speed=-1.0f)
CFrame * frame
virtual void LoadPackData(unsigned int *pack, char *name, CDataAlloc2< 1 > *model_alloc, CDataAlloc2< 1 > *texture_alloc)
virtual void SetScale(float x, float y, float z)
virtual void Step()
virtual void SetRotation(float x, float y, float z)
virtual void Initialize()
float motion_speed
virtual void Draw()
virtual void SetPosition(float x, float y, float z)
virtual void ClothStep(int step)
s8 GetPartySize() const
int GetItem(int item_id, int qty)
int LostItem(int item_id)
s8 GetEquipWeaponSlot(int chara_no)
int SearchItemIndexNo(int item_id)
s32 GetActiveCharaStatus(int chara_no)
int On(int mask)
Definition gamepad.cpp:557
int On2(int mask)
Definition gamepad.cpp:575
int Down2(int mask)
Definition gamepad.cpp:601
int Down(int mask)
Definition gamepad.cpp:583
void MenuModeOff()
Definition gamepad.cpp:617
void MenuModeOn(int threshold)
Definition gamepad.cpp:613
void SetAutoRepeat(int mask, int initial_delay, int repeat_delay)
Definition gamepad.cpp:485
void AutoRepeatOff()
Definition gamepad.cpp:609
s16 mode[10]
Definition savedata.hpp:22
s16 pos[10]
Definition savedata.hpp:21
void IconMoveTarSet(int index, int slot, int item, int count, float x, float y)
int GetMoveIconGole(int slot, int item)
int IsSameItem(int item)
void CheckItemVolume()
void LoopStep(int interval)
s32 x
Definition rect.hpp:18
s32 width
Definition rect.hpp:20
s32 height
Definition rect.hpp:21
s32 y
Definition rect.hpp:19
CMenuCursor * GetMenuCursor()
Definition savedata.cpp:37
CDngStatusData * GetDngStatus()
Definition savedata.cpp:250
s16 * GetCharaName(int chara_no)
Definition savedata.cpp:41
int QuestDungeon(int dungeon_no, int add)
Definition savedata.cpp:535
void * GetConfigData()
Definition savedata.cpp:33
int VisitMap(int map_no, int add)
Definition savedata.cpp:521
short block
Definition texture.hpp:52
u_long tex0
Definition texture.hpp:57
s16 max_hp[6]
ITEM_PACK item_pack
float water_max[6]
float water_now[6]
DNG_CONSUMABLE consumable_items[43]
WEAPON_HAVE chara_weapons[6][11]
s32 active_item_vol[3]
s8 equipped_weapon_slot[6]
s32 res_limit_zone_current
void SetBuildUp(WEAPON_HAVE *have, CCharacter *character, CWeaponLevelUp *load_buffer, int tex_block)
void SetSnd(int from, int to, int step)
void SetLevelUpWeaponData()
void SetStatusBreak(WEAPON_HAVE *have, CCharacter *character, CWeaponLevelUp *load_buffer, int tex_block)
CCharacter effect
void SetLevelUpValue(WEAPON_HAVE *have, CCharacter *character, CWeaponLevelUp *load_buffer, int tex_block)
void WepRecover(WEAPON_HAVE *have, CCharacter *character, CWeaponLevelUp *load_buffer, int tex_block)
void CureEffect(int x, int y, CWeaponLevelUp *load_buffer, int tex_block, int kind)
WEAPON_HAVE * weapon
s32 text_rows
Definition clsmes.hpp:158
s32 auto_pos
Definition clsmes.hpp:172
s32 text_y
Definition clsmes.hpp:152
s32 text_from
Definition clsmes.hpp:198
s32 cursor_y
Definition clsmes.hpp:225
s32 text_x
Definition clsmes.hpp:151
float text_rate_set
Definition clsmes.hpp:193
void DrawMesWin()
Definition clsmes.cpp:2619
s32 wait
Definition clsmes.hpp:204
s32 text_no
Definition clsmes.hpp:197
int GetMesWidth_system(int mes_no)
Definition clsmes.cpp:1193
s32 char_height
Definition clsmes.hpp:154
void Step()
Definition clsmes.cpp:575
s32 mes_no[10]
Definition clsmes.hpp:216
void NeedMesWinWH(int mes_no, int *out)
Definition clsmes.cpp:1476
s32 page_from
Definition clsmes.hpp:199
s32 narrow_gaiji_set
Definition clsmes.hpp:214
int GetMesLen_system(int mes_no)
Definition clsmes.cpp:1089
s32 text_height
Definition clsmes.hpp:161
s32 text_width
Definition clsmes.hpp:160
s32 char_width
Definition clsmes.hpp:153
s32 text_columns
Definition clsmes.hpp:157
s32 text_len
Definition clsmes.hpp:159
s32 value
Definition clsmes.hpp:218
void InitMesWinTbl()
Definition clsmes.cpp:1265
s32 waiting
Definition clsmes.hpp:194
s32 cursor_lit
Definition clsmes.hpp:226
s32 auto_page_wait
Definition clsmes.hpp:206
s32 fade_in
Definition clsmes.hpp:188
s32 space_width
Definition clsmes.hpp:222
s32 clut_now
Definition clsmes.hpp:203
s32 blink
Definition clsmes.hpp:205
s32 narrow_gaiji
Definition clsmes.hpp:215
void * tex_buff
Definition clsmes.hpp:233
s32 cursor_row
Definition clsmes.hpp:224
float fade
Definition clsmes.hpp:187
void SetBuff(short *buff)
Definition clsmes.cpp:456
s32 columns
Definition clsmes.hpp:155
s32 mes_made
Definition clsmes.hpp:207
s32 values[8]
Definition clsmes.hpp:217
s32 style
Definition clsmes.hpp:208
s32 value_narrow
Definition clsmes.hpp:221
s32 tex_block
Definition clsmes.hpp:227
s32 value_signed
Definition clsmes.hpp:219
float text_rate
Definition clsmes.hpp:192
s32 stay_frame
Definition clsmes.hpp:189
s32 edge_alpha
Definition clsmes.hpp:213
s32 clut_default
Definition clsmes.hpp:202
MES_LINE_POS line_pos[10]
Definition clsmes.hpp:228
int MakeMesWin(int mes_no)
Definition clsmes.cpp:1669
s32 value_show
Definition clsmes.hpp:220
void SetBuff_system(short *buff)
Definition clsmes.cpp:462
void Preset(int style)
Definition clsmes.cpp:468
s32 init_030
Definition clsmes.hpp:163
s32 rows
Definition clsmes.hpp:156
s32 space_area
Definition clsmes.hpp:223
float text_at
Definition clsmes.hpp:196
void SetBuffInfo(short *buffer)
void Draw1(int x, int y, int draw_alpha)
void * work_area
WEAPON_HAVE * weapon
ClsMes * message
void NowWeaponStatus(WEAPON_HAVE *selected_weapon)
@ ITEM_SORT_FOOD
Definition itemdata.hpp:23
@ ITEM_SORT_POWDER
Definition itemdata.hpp:25
@ ITEM_SORT_THROW
Definition itemdata.hpp:24
@ ITEM_STACK_MULTI
Definition itemdata.hpp:10
@ ITEM_STACK_SINGLE
Definition itemdata.hpp:11
@ ITEM_STACK_NEVER
Definition itemdata.hpp:12
s16 sphere_weapon_no
Definition itemdata.hpp:592
u_long128 * buffer
Definition dataread.hpp:29
s16 volume
Definition shop.hpp:152
s32 from_page
Definition shop.hpp:148
s32 slot_state
Definition shop.hpp:147
s16 item_no
Definition shop.hpp:151
s32 from_slot
Definition shop.hpp:150
s16 kind_flags
Definition itemdata.hpp:528
s32 stack_kind
Definition itemdata.hpp:532
u32 use_flags
Definition itemdata.hpp:527
PERSONAL_BOARD board
WEAPON_HAVE * target_weapon
s16 quick_item_slot[3]
s16 quick_item_qty[3]
s16 item_vol[103]
s16 item[103]
WEAPON_HAVE weapon
DNG_CONSUMABLE * consumables
ATTACH_LIST held_attach
IHAVEITEM held_item
Definition title.cpp:61
s32 width
Definition rect.hpp:36
s32 height
Definition rect.hpp:37
int y
Definition title.cpp:63
int x
Definition title.cpp:62
s16 vs_monster[10]
Definition itemdata.hpp:666
s16 elem[5]
Definition itemdata.hpp:665
float durability_f
Definition itemdata.hpp:695
char vs_monster[10]
Definition itemdata.hpp:699
ATTACH_LIST attach[6]
Definition itemdata.hpp:701
s8 attach_kind[6]
Definition itemdata.hpp:702
s32 synthesis_count
Definition itemdata.hpp:704
PERSONAL_BOARD board
u8 b
Definition rect.hpp:48
u8 g
Definition rect.hpp:47
u8 a
Definition rect.hpp:49
u8 r
Definition rect.hpp:46