DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
shop.cpp
1#pragma helper_mask_gpr 0x30
2#pragma helper_mask_fpr 0x1000
3#pragma name_counter 761
4
5#include "shop.hpp"
6
7#include <libvu0.h>
8
9#include <cmath>
10#include <cstdio>
11#include <cstdlib>
12#include <cstring>
13
14#include "battlemenu.hpp"
15#include "camera.hpp"
16#include "character.hpp"
17#include "clsmes.hpp"
18#include "dataalloc.hpp"
19#include "dataread.hpp"
20#include "editloop.hpp"
21#include "gamepad.hpp"
22#include "itemdata.hpp"
23#include "mainselect.hpp"
24#include "mathutil.hpp"
25#include "memcard.hpp"
26#include "menu_draw.hpp"
27#include "menu_dungeon.hpp"
28#include "menu_inventory.hpp"
29#include "menu_misc.hpp"
30#include "menuetc.hpp"
31#include "menuitemstep.hpp"
32#include "mglib.hpp"
33#include "rect.hpp"
34#include "savedata.hpp"
35#include "shop_menu.hpp"
36#include "snd.hpp"
37#include "stockitem.hpp"
38#include "texture.hpp"
39#include "userstatus.hpp"
40#include "weaponlevelup.hpp"
41
43s16 ChargeShopMax[3] = {60, 30, 30};
44
46CDataAlloc2<1> ShopCashBuffer(-1);
47
51CDataAlloc2<1> ShopCashBuffer2(-1);
52
54ShopMenuWork ShopMenu;
55
57ShopIconMove ShopDataMove;
58
60CUserStatus *ShopUserStatusPt;
61
63CTexture *ShopBoard;
64
66CStockItem *ShopStockPt;
67
69s32 *ShopBoardInfo;
70
72s32 *ItemBoardInfo;
73
75s32 (*WeaponBoardInfo)[10];
76
78s32 *AttachBoardInfo;
79
81SHOP_ITEMLIST *ShopListPt;
82
84SHOP_ITEMLIST *ShopWorkBuf;
85
87float ShopHelpWinPos[2];
88
90float ShopHelpWinH;
91
93float ShopHelpWinW;
94
95IHAVEITEM *ShopHaveItemPt;
96WEAPON_HAVE *ShopHaveWepPt;
97ATTACH_LIST *ShopHaveAttachPt;
98
100s16 ChargeOrShopFlag;
101
102static int ChargeSelectKey();
103
110 s16 ready;
112 s32 point;
114 s16 mode;
116 s16 cursor;
118 s16 top;
119 u8 unk_1A[6];
121 u_long128 *buffer;
122};
123
124STATIC_ASSERT(sizeof(FishMenuWork) == 0x28);
125
127FishMenuWork FishMenu;
128
143
144STATIC_ASSERT(sizeof(FishRecordMenuWork) == 0x24);
145
147FishRecordMenuWork FishRecordMenu;
148
150CTexture *FishMenuTex;
151
155static inline ITEM_PACK *ShopUserItemPack(CUserStatus *user_status) {
156 return &user_status->item_pack;
157}
158
164
166ITEM_MONEY_ENTRY PriceList[296] = {
167 {300, 150 },
168 {300, 150 },
169 {300, 150 },
170 {300, 150 },
171 {300, 150 },
172 {2, 1 },
173 {2, 1 },
174 {2, 1 },
175 {2, 1 },
176 {2, 1 },
177 {300, 150 },
178 {260, 130 },
179 {260, 130 },
180 {300, 150 },
181 {3000, 600 },
182 {3000, 600 },
183 {3000, 600 },
184 {3000, 600 },
185 {3000, 600 },
186 {3000, 600 },
187 {3000, 600 },
188 {3000, 600 },
189 {3000, 600 },
190 {3000, 600 },
191 {3000, 600 },
192 {3000, 600 },
193 {5000, 1000},
194 {2, 1 },
195 {2, 1 },
196 {2, 1 },
197 {300, 150 },
198 {300, 150 },
199 {300, 150 },
200 {300, 150 },
201 {300, 150 },
202 {300, 150 },
203 {300, 150 },
204 {300, 150 },
205 {300, 150 },
206 {300, 150 },
207 {2, 1 },
208 {2, 1 },
209 {2, 1 },
210 {2, 1 },
211 {2, 1 },
212 {2, 1 },
213 {2, 1 },
214 {2, 1 },
215 {2, 1 },
216 {2, 1 },
217 {2, 1 },
218 {400, 200 },
219 {440, 220 },
220 {380, 190 },
221 {400, 200 },
222 {1000, 500 },
223 {1000, 500 },
224 {1000, 500 },
225 {1000, 500 },
226 {1000, 500 },
227 {1000, 500 },
228 {2, 1 },
229 {2, 1 },
230 {2, 1 },
231 {10, 5 },
232 {30, 15 },
233 {60, 30 },
234 {20, 10 },
235 {130, 65 },
236 {300, 150 },
237 {80, 40 },
238 {120, 60 },
239 {100, 50 },
240 {300, 150 },
241 {60, 30 },
242 {2, 1 },
243 {2, 1 },
244 {2, 1 },
245 {80, 40 },
246 {4, 2 },
247 {100, 50 },
248 {100, 50 },
249 {100, 50 },
250 {100, 50 },
251 {100, 50 },
252 {100, 50 },
253 {80, 40 },
254 {90, 45 },
255 {120, 60 },
256 {80, 40 },
257 {2, 1 },
258 {43, 22 },
259 {2, 1 },
260 {50, 25 },
261 {20, 10 },
262 {100, 50 },
263 {20, 10 },
264 {1000, 500 },
265 {100, 50 },
266 {800, 400 },
267 {800, 400 },
268 {500, 250 },
269 {200, 100 },
270 {2, 1 },
271 {500, 250 },
272 {300, 150 },
273 {450, 225 },
274 {400, 200 },
275 {420, 210 },
276 {380, 190 },
277 {2, 1 },
278 {1000, 1000},
279 {300, 150 },
280 {2, 1 },
281 {2, 1 },
282 {2, 1 },
283 {400, 200 },
284 {400, 200 },
285 {400, 200 },
286 {2, 1 },
287 {2, 1 },
288 {2, 1 },
289 {2, 1 },
290 {2, 1 },
291 {2, 1 },
292 {2, 1 },
293 {2, 1 },
294 {2, 1 },
295 {2, 1 },
296 {2, 1 },
297 {2, 1 },
298 {2, 1 },
299 {2, 1 },
300 {2, 1 },
301 {2, 1 },
302 {2, 1 },
303 {2, 1 },
304 {2, 1 },
305 {2, 1 },
306 {2, 1 },
307 {2, 1 },
308 {2, 1 },
309 {2, 1 },
310 {300, 150 },
311 {300, 150 },
312 {180, 90 },
313 {2, 1 },
314 {500, 250 },
315 {800, 400 },
316 {800, 400 },
317 {1000, 500 },
318 {2, 1 },
319 {2, 1 },
320 {2, 1 },
321 {50, 25 },
322 {2, 1 },
323 {2, 1 },
324 {2, 1 },
325 {2, 1 },
326 {2, 1 },
327 {2, 1 },
328 {2, 1 },
329 {2, 1 },
330 {2, 1 },
331 {20, 10 },
332 {2, 1 },
333 {2, 1 },
334 {2, 1 },
335 {2, 1 },
336 {2, 1 },
337 {2, 1 },
338 {2, 1 },
339 {2, 1 },
340 {2, 1 },
341 {2, 1 },
342 {2, 1 },
343 {2, 1 },
344 {2, 1 },
345 {300, 75 },
346 {500, 125 },
347 {2500, 625 },
348 {700, 175 },
349 {800, 200 },
350 {1000, 250 },
351 {400, 100 },
352 {2000, 500 },
353 {3000, 750 },
354 {2000, 500 },
355 {2400, 600 },
356 {500, 125 },
357 {3000, 750 },
358 {3000, 750 },
359 {2, 1 },
360 {3000, 750 },
361 {2, 1 },
362 {2, 1 },
363 {2, 1 },
364 {2, 1 },
365 {2, 0 },
366 {2, 1 },
367 {2, 1 },
368 {2, 1 },
369 {800, 200 },
370 {920, 230 },
371 {2, 1 },
372 {900, 225 },
373 {990, 248 },
374 {2500, 625 },
375 {1500, 375 },
376 {2, 1 },
377 {1000, 250 },
378 {2000, 500 },
379 {940, 235 },
380 {1500, 375 },
381 {2, 1 },
382 {2, 1 },
383 {2, 1 },
384 {2, 1 },
385 {2, 1 },
386 {2, 1 },
387 {360, 90 },
388 {600, 150 },
389 {1000, 250 },
390 {400, 100 },
391 {900, 225 },
392 {1000, 250 },
393 {1200, 300 },
394 {2, 1 },
395 {2, 1 },
396 {500, 125 },
397 {600, 150 },
398 {2, 1 },
399 {900, 225 },
400 {2, 1 },
401 {2, 1 },
402 {500, 125 },
403 {700, 175 },
404 {800, 200 },
405 {850, 212 },
406 {1000, 250 },
407 {400, 100 },
408 {900, 225 },
409 {1500, 375 },
410 {2, 1 },
411 {2, 1 },
412 {2, 1 },
413 {850, 212 },
414 {200, 50 },
415 {2, 1 },
416 {1000, 250 },
417 {2, 1 },
418 {2, 1 },
419 {400, 100 },
420 {700, 175 },
421 {600, 150 },
422 {720, 180 },
423 {800, 200 },
424 {1200, 300 },
425 {1400, 350 },
426 {2, 1 },
427 {2, 1 },
428 {2, 1 },
429 {400, 100 },
430 {300, 75 },
431 {2, 1 },
432 {720, 180 },
433 {2, 1 },
434 {2, 1 },
435 {800, 200 },
436 {1000, 250 },
437 {1200, 300 },
438 {1500, 375 },
439 {1700, 425 },
440 {2000, 500 },
441 {2, 1 },
442 {2, 1 },
443 {2, 1 },
444 {2, 1 },
445 {300, 75 },
446 {1800, 450 },
447 {800, 200 },
448 {1000, 250 },
449 {2, 1 },
450 {2, 1 },
451 {3000, 750 },
452 {3200, 800 },
453 {3300, 825 },
454 {3400, 850 },
455 {4000, 1000},
456 {5500, 1375},
457 {6500, 1625},
458 {2, 1 },
459 {2, 1 },
460 {1500, 375 },
461 {3400, 850 },
462 {1000, 250 },
463};
464
470static s16 ItemShopList2[18][20] = {
471 {ITEM_BREAD, ITEM_REGULAR_WATER, ITEM_REPAIR_POWDER, ITEM_AUTO_REPAIR_POWDER, ITEM_ESCAPE_POWDER, ITEM_STAND_IN_POWDER, ITEM_REVIVAL_POWDER, ITEM_ANTIDOTE_DRINK, ITEM_SOAP, ITEM_BOMB, ITEM_DRAN_S_FEATHER, ITEM_ATTACH_ATTACK, ITEM_ATTACH_ENDURANCE, ITEM_ATTACH_FIRE, ITEM_ATTACH_ICE, ITEM_ATTACH_THUNDER, ITEM_ATTACH_WIND, ITEM_ATTACH_HOLY, ITEM_ATTACH_DINOSLAYER, ITEM_GOLD_BULLION},
472 {ITEM_BREAD, ITEM_CHEESE, ITEM_TASTY_WATER, ITEM_REVIVAL_POWDER, ITEM_REPAIR_POWDER, ITEM_AUTO_REPAIR_POWDER, ITEM_STAND_IN_POWDER, ITEM_ESCAPE_POWDER, ITEM_ATTACH_PLANT_BUSTER, ITEM_ANTIDOTE_DRINK, ITEM_SOAP, ITEM_DRAN_S_FEATHER, ITEM_GOLD_BULLION, ITEM_WEAPON_WISE_OWL_SWORD, ITEM_MIMI, ITEM_PRICKLY, -1},
473 {ITEM_FLAPPING_FISH, ITEM_FLAPPING_FISH, ITEM_FLAPPING_FISH, ITEM_EVY, ITEM_EVY, ITEM_PETITE_FISH, ITEM_PETITE_FISH, ITEM_ICE_BLOCK, ITEM_ICE_BLOCK, ITEM_ICE_BLOCK, ITEM_REGULAR_WATER, ITEM_TASTY_WATER, ITEM_PREMIUM_WATER, ITEM_STAND_IN_POWDER, -1},
474 {ITEM_REGULAR_WATER, ITEM_TASTY_WATER, ITEM_PREMIUM_WATER, ITEM_STAMINA_DRINK, ITEM_ANTIDOTE_DRINK, ITEM_HOLY_WATER, -1},
475 {ITEM_REGULAR_WATER, ITEM_TASTY_WATER, ITEM_PREMIUM_WATER, ITEM_BREAD, ITEM_STAMINA_DRINK, ITEM_ATTACH_ATTACK, ITEM_ATTACH_ENDURANCE, ITEM_ATTACH_SPEED, ITEM_ATTACH_MAGICAL_POWER, -1},
476 {ITEM_REGULAR_WATER, ITEM_TASTY_WATER, ITEM_PREMIUM_WATER, ITEM_STAMINA_DRINK, ITEM_CHEESE, ITEM_ATTACH_FIRE, ITEM_ATTACH_ICE, ITEM_ATTACH_THUNDER, ITEM_ATTACH_WIND, ITEM_ATTACH_HOLY, -1},
477 {ITEM_REGULAR_WATER, ITEM_TASTY_WATER, ITEM_PREMIUM_WATER, ITEM_STAMINA_DRINK, ITEM_PREMIUM_CHICKEN, ITEM_BOMB, ITEM_ATTACH_SEA_KILLER, ITEM_ATTACH_MAGE_SLAYER, ITEM_ATTACH_UNDEAD_BUSTER, -1},
478 {ITEM_THROBBING_CHERRY, ITEM_GOOEY_PEACH, ITEM_BOMB_NUTS, ITEM_POISONOUS_APPLE, ITEM_MELLOW_BANANA, ITEM_REPAIR_POWDER, ITEM_REVIVAL_POWDER, ITEM_STAND_IN_POWDER, -1},
479 {ITEM_WEAPON_KITCHEN_KNIFE, ITEM_WEAPON_GLADIUS, ITEM_WEAPON_BONE_SLINGSHOT, ITEM_WEAPON_BIG_BUCKS_HAMMER, ITEM_WEAPON_PLATINUM_RING, ITEM_REPAIR_POWDER, ITEM_AUTO_REPAIR_POWDER, ITEM_STAND_IN_POWDER, ITEM_REVIVAL_POWDER, ITEM_ESCAPE_POWDER, ITEM_DRAN_S_FEATHER, ITEM_GOLD_BULLION, -1},
480 {ITEM_PREMIUM_WATER, ITEM_CHEESE, ITEM_PREMIUM_CHICKEN, ITEM_MIGHTY_HEALING, ITEM_BOMB, ITEM_REPAIR_POWDER, ITEM_AUTO_REPAIR_POWDER, ITEM_STAND_IN_POWDER, ITEM_REVIVAL_POWDER, ITEM_ESCAPE_POWDER, ITEM_ATTACH_WIND, ITEM_ATTACH_STONE_BREAKER, ITEM_ATTACH_SKY_HUNTER, ITEM_DRAN_S_FEATHER, ITEM_GOLD_BULLION, ITEM_POTATO_CAKE, -1},
481 {ITEM_REGULAR_WATER, ITEM_TASTY_WATER, ITEM_PREMIUM_WATER, ITEM_PREMIUM_CHICKEN, ITEM_BOMB, ITEM_ATTACH_BEAST_BUSTER, ITEM_STAND_IN_POWDER, ITEM_REVIVAL_POWDER, ITEM_ESCAPE_POWDER, ITEM_REPAIR_POWDER, ITEM_AUTO_REPAIR_POWDER, ITEM_DRAN_S_FEATHER, ITEM_WEAPON_JACKAL, ITEM_WEAPON_SNAIL, ITEM_GOLD_BULLION, -1},
482 {ITEM_PREMIUM_WATER, ITEM_PREMIUM_CHICKEN, ITEM_MIGHTY_HEALING, ITEM_STAND_IN_POWDER, ITEM_REVIVAL_POWDER, ITEM_ESCAPE_POWDER, ITEM_REPAIR_POWDER, ITEM_AUTO_REPAIR_POWDER, ITEM_DRAN_S_FEATHER, ITEM_GOLD_BULLION, -1},
483 {ITEM_FIRE_GEM, ITEM_ICE_GEM, ITEM_THUNDER_GEM, ITEM_WIND_GEM, ITEM_HOLY_GEM, ITEM_ATTACH_FIRE, ITEM_ATTACH_ICE, ITEM_ATTACH_THUNDER, ITEM_ATTACH_WIND, ITEM_ATTACH_HOLY, ITEM_ATTACH_SEA_KILLER, ITEM_ATTACH_MAGE_SLAYER, ITEM_GOLD_BULLION, -1},
484 {ITEM_BREAD, ITEM_REGULAR_WATER, ITEM_REPAIR_POWDER, ITEM_AUTO_REPAIR_POWDER, ITEM_REVIVAL_POWDER, ITEM_STAND_IN_POWDER, ITEM_ESCAPE_POWDER, ITEM_ANTIDOTE_DRINK, ITEM_GOLD_BULLION, -1},
485 {ITEM_BREAD, ITEM_CHEESE, ITEM_TASTY_WATER, ITEM_REVIVAL_POWDER, ITEM_REPAIR_POWDER, ITEM_AUTO_REPAIR_POWDER, ITEM_STAND_IN_POWDER, ITEM_ESCAPE_POWDER, ITEM_ATTACH_PLANT_BUSTER, ITEM_ANTIDOTE_DRINK, ITEM_SOAP, ITEM_DRAN_S_FEATHER, ITEM_GOLD_BULLION, -1},
486 {ITEM_PREMIUM_WATER, ITEM_CHEESE, ITEM_HOLY_WATER, ITEM_SOAP, ITEM_MIGHTY_HEALING, ITEM_BOMB, ITEM_STAND_IN_POWDER, ITEM_REVIVAL_POWDER, ITEM_ESCAPE_POWDER, ITEM_REPAIR_POWDER, ITEM_AUTO_REPAIR_POWDER, ITEM_DRAN_S_FEATHER, ITEM_GOLD_BULLION, -1},
487 {ITEM_ATTACH_GARNET, ITEM_ATTACH_AMETHYST, ITEM_ATTACH_AQUAMARINE, ITEM_ATTACH_DIAMOND, ITEM_ATTACH_EMERALD, ITEM_ATTACH_PEARL, ITEM_ATTACH_RUBY, ITEM_ATTACH_PERIDOT, ITEM_ATTACH_SAPPHIRE, ITEM_ATTACH_OPAL, ITEM_ATTACH_TOPAZ, ITEM_ATTACH_TURQUOISE, -1},
488 {ITEM_ATTACH_ATTACK, ITEM_ATTACH_ENDURANCE, ITEM_ATTACH_SPEED, ITEM_ATTACH_MAGICAL_POWER, ITEM_ATTACH_DINOSLAYER, ITEM_ATTACH_UNDEAD_BUSTER, ITEM_ATTACH_SEA_KILLER, ITEM_ATTACH_STONE_BREAKER, ITEM_ATTACH_PLANT_BUSTER, ITEM_ATTACH_BEAST_BUSTER, ITEM_ATTACH_SKY_HUNTER, ITEM_ATTACH_MAGE_SLAYER, -1},
489};
490
491static void DrawSellTicket_2(int x, int y, int clip_top, int clip_bottom, int alpha);
492
493static void SetShopTalkMsgPos();
494
495static void DrawCheckButton(int x, int y, int alpha);
496
497static void ItemShopGoodInitialize(int shop_no);
498
499static void ShopCancelGoodReturn2();
500
501s16 *GetItemShopList(int shop_no) {
502 return ItemShopList2[shop_no];
503}
504
505void InitShopItemListData(SHOP_ITEMLIST *item_list) {
506 if (item_list != NULL) {
507 item_list->item_no = 0;
508 memset(&item_list->data, 0, sizeof(item_list->data));
509 }
510}
511
512void ShopIconMove::IconMoveTarSet(int slot_no, int icon_no, int item_no, MENU_ITEMDATA *item_data, float start_x, float start_y, int to_stock) {
513 this->to_stock = to_stock;
514 this->item_no = item_no;
515 this->slot_no = slot_no;
516 this->icon_no = icon_no;
517 memcpy(&this->data, item_data, sizeof(this->data));
518 this->pos_x = start_x;
519 this->pos_y = start_y;
520}
521
522int ShopIconMove::IconAutoMove(int item_shop, int force_arrive) {
523 if (item_no < ITEM_ATTACH_START) {
524 return -1;
525 }
526
527 int col_x = icon_no % 5 * 0x28;
528 int row_y = icon_no / 5 * 0x28;
529 int target_x;
530 int target_y;
531
532 if (item_shop) {
533 target_x = col_x + 0x16A;
534 target_y = row_y + 0x86;
535 } else {
536 target_x = col_x + 0x16A;
537 target_y = row_y + 0x90;
538 }
539
540 if (to_stock) {
541 target_x = col_x + 0x3E;
542 target_y = row_y + 0x90;
543 }
544
545 pos_x += (float) (target_x - (int) pos_x) / 4.0f;
546 pos_y += (float) (target_y - (int) pos_y) / 4.0f;
547
548 int arrived = false;
549
550 if (force_arrive || (float) abs((int) (pos_x - (float) target_x)) < 4.0f) {
551 pos_x = target_x;
552 arrived++;
553 }
554
555 if (force_arrive || (float) abs((int) (pos_y - (float) target_y)) < 4.0f) {
556 pos_y = target_y;
557 arrived++;
558 }
559
560 if (arrived >= 2) {
561 s32 *board_info;
562
563 switch (WhatIsKindofItem(item_no)) {
564 case BOARD_PAGE_ITEM:
565 if (to_stock) {
566 s16 item = item_no;
567 s16 volume = data.volume;
568 ShopStockPt->SetItemToPos(slot_no, &item, &volume);
569 } else {
570 ITEM_PACK *pack = ShopUserItemPack(ShopUserStatusPt);
571 pack->item[slot_no] = item_no;
572 pack->item_vol[slot_no] = data.volume;
573 board_info = &ItemBoardInfo[slot_no];
574 }
575
576 break;
577 case BOARD_PAGE_ATTACH:
578 if (to_stock) {
579 ShopStockPt->SetAttachToPos(slot_no, &data.attach);
580 } else {
581 DNG_CONSUMABLE *attach = ShopUserStatusPt->consumable_items;
582 memcpy(&attach[slot_no], &data.attach, sizeof(DNG_CONSUMABLE));
583 attach[slot_no].id = item_no;
584 board_info = &AttachBoardInfo[slot_no];
585 }
586
587 break;
588 case BOARD_PAGE_WEAPON:
589 if (to_stock) {
590 ShopStockPt->SetWepToPos(slot_no, &data.weapon);
591 } else {
592 int chara_no = slot_no / 10;
593 CUserStatus *status = ShopUserStatusPt;
594 WEAPON_HAVE *row = status->chara_weapons[chara_no];
595 WEAPON_HAVE *weapon = &row[slot_no % 10];
596 memcpy(weapon, &data.weapon, sizeof(WEAPON_HAVE));
597 weapon->item_no = item_no;
598 board_info = &WeaponBoardInfo[0][slot_no];
599 }
600
601 break;
602 }
603
604 if (ChargeOrShopFlag) {
605 *board_info = SHOP_SLOT_PLAYER_ITEM;
606 }
607
608 spare = -1;
609 slot_no = -1;
610 icon_no = -1;
611 item_no = -1;
612 pos_y = 0.0f;
613 pos_x = 0.0f;
614 memset(&data, 0, sizeof(data));
615 }
616
617 return 0;
618}
619
621 if (item_no >= ITEM_ATTACH_START) {
622 int kind = WhatIsKindofItem(item_no);
623
624 if (ShopMenu.board.page == kind) {
625 int num = 0;
626 int item = item_no;
627
628 if (item == ITEM_ATTACH_SYNTHESIS_SPHERE) {
629 num = data.param[1];
630 }
631
632 if (item >= ITEM_ATTACH_STAT_START && item < ITEM_ATTACH_GEM_START) {
633 num = data.param[item - ITEM_ATTACH_STAT_START + 4];
634 }
635
636 DrawIconParts(item, pos_x, pos_y, 0, 0x280, 0x80, num);
637 }
638 }
639}
640
648static s16 GetItemMoney(int item_no, int sell) {
649 if (sell != 0) {
650 return PriceList[item_no - ITEM_ATTACH_START].sell_price;
651 }
652
653 return PriceList[item_no - ITEM_ATTACH_START].buy_price;
654}
655
656int ShopNoInput(int *tex_block, int shop_no, int mode) {
657 if (shop_no < 0 || shop_no > 200) {
658 shop_no = 0;
659 }
660
661 if (shop_no < 100) {
662 if (shop_no > 20) {
663 shop_no = 0;
664 }
665
666 InitItemShop2(tex_block, shop_no, mode);
667 ChargeOrShopFlag = SHOP_KIND_ITEM;
668 } else {
669 shop_no -= 100;
670
671 if (shop_no > 5) {
672 shop_no = 0;
673 }
674
675 InitChargeShop(tex_block, shop_no, mode);
676 ChargeOrShopFlag = SHOP_KIND_CHARGE;
677 }
678
679 return 1;
680}
681
682void InitAllHaveData() {
683 InitHaveData(ShopHaveItemPt);
684 InitHaveWep(ShopHaveWepPt);
685 InitHaveAttach(ShopHaveAttachPt);
686 ShopHaveItemPt->slot_state = SHOP_SLOT_EMPTY;
687}
688
689int CommonShopLoop() {
690 int done = 0;
691
692 ShopMenu.key_used = 0;
693
694 switch (ChargeOrShopFlag) {
695 case SHOP_KIND_CHARGE:
696 done = ChargeShopLoop();
697 break;
698 case SHOP_KIND_ITEM:
699 done = ItemShopLoop2();
700 break;
701 }
702
703 return done;
704}
705
713static void ShopPolySetInit(int shop_kind, int shop_no) {
714 float place[2][18][3] = {
715 {
716 {-7.84f, -15.5f, 0.9f},
717 {-7.3f, -9.555f, 0.25f},
718 {-7.04f, -21.21f, 1.0f},
719 {-7.56f, -18.967f, 1.0f},
720 {-7.0f, -14.0f, 1.0f},
721 {-7.3359f, -15.818726f, 0.95f},
722 {0.0f, 0.0f, 0.0f},
723 {0.0f, 0.0f, 0.0f},
724 {0.0f, 0.0f, 0.0f},
725 {0.0f, 0.0f, 0.0f},
726 {0.0f, 0.0f, 0.0f},
727 {0.0f, 0.0f, 0.0f},
728 {0.0f, 0.0f, 0.0f},
729 {0.0f, 0.0f, 0.0f},
730 {0.0f, 0.0f, 0.0f},
731 {0.0f, 0.0f, 0.0f},
732 {0.0f, 0.0f, 0.0f},
733 {0.0f, 0.0f, 0.0f},
734 },
735 {
736 {-7.01f, -17.0f, 0.9f},
737 {-7.21f, -7.8f, 0.5f},
738 {-7.46f, -19.6f, 1.0f},
739 {-8.0665f, -18.923f, 1.0f},
740 {-8.0665f, -18.923f, 1.0f},
741 {-8.0665f, -18.923f, 1.0f},
742 {-8.0665f, -18.923f, 1.0f},
743 {-7.0f, -20.5f, 1.0f},
744 {-7.5378f, -15.362f, 0.8f},
745 {-7.0f, -19.0f, 0.8f},
746 {-7.0f, -15.0f, 1.0f},
747 {-7.0f, -17.0f, 1.0f},
748 {-7.6f, -18.7f, 0.8f},
749 {-7.01f, -17.2f, 0.9f},
750 {-7.21f, -7.8f, 0.5f},
751 {-7.5378f, -18.5f, 0.8f},
752 {-7.0f, -17.0f, 1.0f},
753 {-7.0f, -17.0f, 1.0f},
754 },
755 };
756 float turn[2][18][4] = {
757 {
758 {0.005f, 0.26413f, 0.0f, 0.0f},
759 {0.05f, 0.249446f, 0.0f, 0.0f},
760 {-0.033f, 0.2382f, 0.0f, 0.0f},
761 {0.0f, 0.0f, 0.0f, 0.0f},
762 {0.0f, 0.0f, 0.0f, 0.0f},
763 {0.0f, 0.0f, 0.0f, 0.0f},
764 {0.0f, 0.0f, 0.0f, 0.0f},
765 {0.0f, 0.0f, 0.0f, 0.0f},
766 {0.0f, 0.0f, 0.0f, 0.0f},
767 {0.0f, 0.0f, 0.0f, 0.0f},
768 {0.0f, 0.0f, 0.0f, 0.0f},
769 {0.0f, 0.0f, 0.0f, 0.0f},
770 {0.0f, 0.0f, 0.0f, 0.0f},
771 {0.0f, 0.0f, 0.0f, 0.0f},
772 {0.0f, 0.0f, 0.0f, 0.0f},
773 {0.0f, 0.0f, 0.0f, 0.0f},
774 {0.0f, 0.0f, 0.0f, 0.0f},
775 {0.0f, 0.0f, 0.0f, 0.0f},
776 },
777 {
778 {-0.177612f, 0.23744f, 0.0f, 0.0f},
779 {-0.177612f, 0.23744f, 0.0f, 0.0f},
780 {-0.026733f, 0.251785f, 0.0f, 0.0f},
781 {-0.070679f, 0.271298f, -0.02832f, 0.0f},
782 {-0.050537f, 0.255213f, 0.0f, 0.0f},
783 {-0.026733f, 0.251785f, 0.0f, 0.0f},
784 {-0.026733f, 0.251785f, 0.0f, 0.0f},
785 {-0.026733f, 0.251785f, 0.0f, 0.0f},
786 {-0.026733f, 0.251785f, 0.0f, 0.0f},
787 {-0.026733f, 0.251785f, 0.0f, 0.0f},
788 {-0.026733f, 0.251785f, 0.0f, 0.0f},
789 {-0.026733f, 0.251785f, 0.0f, 0.0f},
790 {-0.026733f, 0.251785f, 0.0f, 0.0f},
791 {-0.026733f, 0.251785f, 0.0f, 0.0f},
792 {-0.026733f, 0.251785f, 0.0f, 0.0f},
793 {-0.026733f, 0.251785f, 0.0f, 0.0f},
794 {-0.026733f, 0.251785f, 0.0f, 0.0f},
795 {0.0f, 0.0f, 0.0f, 0.0f},
796 },
797 };
798 float position[4];
799 float scale[4];
800 float rotation[4];
801
802 position[0] = place[shop_kind][shop_no][0];
803 position[1] = place[shop_kind][shop_no][1];
804 position[2] = 1.0f;
805 position[3] = 0.0f;
806
807 for (int i = 0; i < 4; i++) {
808 scale[i] = place[shop_kind][shop_no][2];
809 rotation[i] = turn[shop_kind][shop_no][i];
810 }
811
812#ifdef PAL
813 position[1] -= 0.5f;
814#endif
815 MenuCharaFrame.SetPosition(position);
816 MenuCharaFrame.SetScale(scale);
817 MenuCharaFrame.SetRotation(rotation);
818}
819
827static void SetItemShopTalkMode(int talk_mode, int msg_mode) {
828 if (talk_mode >= 0) {
829 ShopMenu.talk_mode = talk_mode;
830 }
831
832 if (msg_mode >= 0) {
833 ShopMenu.msg_mode = msg_mode;
834 }
835
836 if (ShopMenu.msg_mode == SHOP_MSG_TALKING) {
837 CommonMenuMes3.mes_made = -1;
838 ShopMenu.msg_no = -1;
839 }
840}
841
849static void ShopIconDraw(short *item_no, unsigned char *value, int count, int x, int y, int clip_top, int clip_bottom, int alpha) {
850 int draw_x = x;
851 int draw_y = y;
852 int i;
853
854 for (i = 0; i < count; i++) {
855 DrawIconParts(item_no[i], draw_x, draw_y, clip_top, clip_bottom, alpha, value[i]);
856 draw_x += 0x28;
857
858 if (i % 5 == 4) {
859 draw_x = x;
860 draw_y += 0x28;
861 }
862 }
863}
864
872static void ChargeShopLRDraw(int alpha) {
873 int x = -1;
874 int gap = x;
875
876 switch (ShopMenu.side) {
877 case SHOP_SIDE_STOCK:
878 x = 0x38;
879 gap = 0xD8;
880 break;
881 case SHOP_SIDE_PERSONAL:
882 x = 0x146;
883 gap = 0xE6;
884 break;
885 }
886
887 if (0 < x) {
888 CRect_i_ texel(0x62, 0x14, 0x1A, 0x18);
889 int y = 66.0f + 4.0f * sinf(PI * (CursorVibeCnt % 79 - 40) / 40.0f);
890
891 DrawMenu2DSprite(PerBoardTex, CRect_i_(x, y, texel.width, texel.height), texel, alpha);
892 texel.x += texel.width;
893 DrawMenu2DSprite(PerBoardTex, CRect_i_(x + gap, y, texel.width, texel.height), texel, alpha);
894 }
895}
896
904static void ShopCurDraw(int x, int y, int pos, int top, int mode, int select, int alpha) {
905 float cur_x;
906 float cur_y;
907 int frame_x;
908 int frame_y;
909 int vibe = select * 0x20 + 0x40;
910 int width;
911 int height;
912
913 height = width = 0x26;
914
915 switch (mode) {
916 case 0: {
917 cur_x = x + pos % 5 * 0x28;
918 int row = pos / 5 - top;
919
920 if (row < 0) {
921 row = 0;
922 }
923
924 if (row > 3) {
925 row = 3;
926 }
927
928 cur_y = y + row * 0x28;
929
930 if (ShopMenu.board.cursor_area == PERSONAL_BOARD_AREA_TRASH) {
931#ifdef PAL
932 cur_x = x + 0xE2;
933#else
934 cur_x = x + 0xD2;
935#endif
936 cur_y = y + 0x8C;
937 }
938
939 frame_x = (int) cur_x + 0x1E;
940 frame_y = (int) cur_y - 0xA;
941 break;
942 }
943 case 1:
944 cur_x = x + 0x90;
945 cur_y = y + 0x9E;
946 frame_x = (int) cur_x + 0x1E;
947 frame_y = (int) cur_y - 0xA;
948 width = 0x64;
949 break;
950 }
951
952 DrawMenuWaku(frame_x, frame_y, width, height, 0, StayTex, alpha);
953
954 if (select) {
955 cur_x += 34.0f;
956 cur_y += 20.0f;
957 }
958
959 ShopMenu.cursor_x += (cur_x - ShopMenu.cursor_x) / 4.0f;
960 ShopMenu.cursor_y += (cur_y - ShopMenu.cursor_y) / 4.0f;
961
962 if (select == 2) {
963 DrawMenuVibeItem(ShopMenu.cursor_x, ShopMenu.cursor_y, 0, -0xE, alpha);
964 }
965
966 DrawMenuObjectVibe(ShopMenu.cursor_x, ShopMenu.cursor_y, 1, vibe);
967 CursorVibeCnt++;
968
969 if (CursorVibeCnt >= 0x202FBF00) {
970 CursorVibeCnt = 0;
971 }
972}
973
981static void DrawShopIcon(int x, int y, int selected, int alpha) {
982 int v = 0x50;
983 int width = 0xA2;
984
985 if (selected) {
986 v += 0x28;
987 width = 0xC8;
988 }
989
990 DrawMenu2DSprite(ShopBoard, CRect_i_(x, y, width, 0x28), CRect_i_(0x14, v, width, 0x28), alpha);
991}
992
1000static int IsEnableCharge(int item_no) {
1001 int enable = false;
1002
1003 if (item_no >= ITEM_WEAPON_START) {
1004 int chara_no = WhoIsWeaponEquip(item_no);
1005 CUserStatus *status = ShopUserStatusPt;
1006 WEAPON_HAVE *weapons = status->chara_weapons[chara_no];
1007 int default_no = GetDefaultWeaponNo(chara_no);
1008
1009 for (int i = 0; i < 10; i++) {
1010 int weapon_no = weapons[i].item_no;
1011
1012 if (weapon_no == default_no || weapon_no == default_no + 1) {
1013 enable = true;
1014 break;
1015 }
1016 }
1017
1018 if (ShopUserStatusPt->party_size - 1 < chara_no) {
1019 enable = true;
1020 }
1021
1022 if (ShopMenu.board.held_equipped_slot >= 0) {
1023 enable = false;
1024 }
1025 } else {
1026 enable = true;
1027
1028 if (item_no == ITEM_MOON_ORB) {
1029 enable = false;
1030 }
1031 }
1032
1033 return enable;
1034}
1035
1043static void ShopMenuInit(int *tex_block, int shop_no, int mode) {
1044 u_long128 *buffer;
1045 int limit;
1046
1047 buffer = BtlMenuBufferSet(mode);
1048 buffer = MenuCalcBufAlignment(buffer);
1049 limit = EdMenuBuffer.limit >> 1;
1050 ShopCashBuffer.base = (u_char *) buffer;
1051 ShopCashBuffer.limit = limit;
1052 ShopCashBuffer.used = 0;
1053 ShopUserStatusPt = (CUserStatus *) SaveData->GetDngStatus();
1054 ShopMenu.lang = GetMenuLangFlag();
1055 StartReadBG();
1056 ShopCashBuffer.Alloc((LoadFileBGMenuData("itemshop.pak", buffer) >> 4) + 0x102);
1057 ShopMenu.shop_no = shop_no;
1058 ShopMenu.mode = mode;
1059 ShopMenu.tex_block = tex_block[0];
1060 ShopMenu.ready = 0;
1061 ShopMenu.person_tex_block = tex_block[1];
1062 ShopMenu.person_state = 1;
1063 ShopMenu.alpha = 0;
1064 ShopMenu.side = SHOP_SIDE_PERSONAL;
1065 InitPersonalBoardMode(ShopUserStatusPt, &ShopMenu.board, PERSONAL_BOARD_ITEM, BOARD_PAGE_ITEM);
1066 ShopHaveItemPt = &ShopMenu.board.held_item;
1067 ShopHaveWepPt = &ShopMenu.board.weapon;
1068 ShopHaveAttachPt = &ShopMenu.board.held_attach;
1069 ShopMenu.stock_top_row = 0;
1070 ShopMenu.stock_row_offset = 0;
1071 ShopMenu.step_count = 0;
1072 ShopMenu.talk_mode = SHOP_TALK_FADE_IN;
1073 StayTex = TexManager.GetTexture("stayframe", -1);
1074 ItemVolumeStep.CheckItemVolume();
1075 ShopDataMove.spare = -1;
1076 ShopDataMove.slot_no = -1;
1077 ShopDataMove.icon_no = -1;
1078 ShopDataMove.item_no = -1;
1079 ShopDataMove.pos_y = 0.0f;
1080 ShopDataMove.pos_x = 0.0f;
1081 memset(&ShopDataMove.data, 0, sizeof(ShopDataMove.data));
1082 SetMenuTrushMark(ShopUserItemPack(ShopUserStatusPt));
1083 GamePad.SetAutoRepeat(PAD_DPAD, 0x1E, 5);
1084 GamePad.MenuModeOn(0x78);
1085}
1086
1094static void ShopMenuExit() {
1095 ITEM_PACK *pack = ShopUserItemPack(ShopUserStatusPt);
1096 int i;
1097 int j;
1098
1099 pack->item_count = 0;
1100
1101 for (i = 0; i < 3; i++) {
1102 if (pack->quick_item_slot[i] >= ITEM_DUNGEON_START) {
1103 pack->item_count += (s8) pack->quick_item_qty[i];
1104 }
1105 }
1106
1107 for (j = 0; j < pack->num; j++) {
1108 if (pack->item[j] >= ITEM_DUNGEON_START) {
1109 pack->item_count++;
1110 }
1111 }
1112
1113 DeleteMenuTrushMark();
1114 CommonMenuMes3.auto_pos = MES_POS_NONE;
1115 AtoraNameMes.rows = 4;
1116 TexManager.DeleteTextureBlock(ShopMenu.tex_block);
1117 TexManager.DeleteTextureBlock(ShopMenu.person_tex_block);
1118 TexManager.CleanUpTextureList();
1119 GamePad.AutoRepeatOff();
1120 GamePad.MenuModeOff();
1121}
1122
1123void ShopTextureLoadFix() {
1124 LOADTEXTURE_INFO2 info[3] = {
1125 {"#frame_imageshop#640#" SCREEN_HEIGHT_STR "#4", 0, 0},
1126 {NULL, 0, 0},
1127 {NULL, 0, 0},
1128 };
1129
1130 info[0].block_no = ShopMenu.tex_block;
1131 info[1].block_no = ShopMenu.tex_block;
1132 BG_READ_INFO *file = GetReadBGFile(0);
1133 info[1].name = (char *) GetPackFile((u_int *) file->buffer, "itemshop.img", NULL);
1134 TexManager.DeleteTextureBlock(ShopMenu.tex_block);
1135 TexManager.CleanUpTextureList();
1136 TexManager.LoadTextureBlockEX(-1, info);
1137 ShopBoard = TexManager.GetTexture("shopbrd", ShopMenu.tex_block);
1138 PerBoardTex = TexManager.GetTexture("perbrd", ShopMenu.tex_block);
1139 WepIcon = TexManager.GetTexture("wepicon", ShopMenu.tex_block);
1140 ItemIcon = TexManager.GetTexture("itemicon", ShopMenu.tex_block);
1141 ShopMenu.ready = 1;
1142 s16 *shop_messages = (s16 *) GetPackFile((u_int *) file->buffer, "itemshop.bin", NULL);
1143 s16 *keeper_messages = (s16 *) GetPackFile((u_int *) file->buffer, "shopman.bin", NULL);
1144 InitMenuMesSet(MENU_MES_SET_SHOP, shop_messages);
1145 CommonMenuMes3.SetBuff(keeper_messages);
1146}
1147
1155static void ShopFadeoutDraw() {
1156 int alpha = 0;
1157
1158 switch (ShopMenu.talk_mode) {
1159 case SHOP_TALK_FADE_IN:
1160 alpha = 0x80 - ShopMenu.step_count * 3;
1161 break;
1162 case SHOP_TALK_FADE_OUT:
1163 alpha = ShopMenu.step_count * 3 + 0x40;
1164 break;
1165 }
1166
1167 if (alpha < 0) {
1168 alpha = 0;
1169 }
1170
1171 if (alpha > 0x80) {
1172 alpha = 0x80;
1173 }
1174
1175 FrameImageDraw(0x40, alpha);
1176
1177 switch (ShopMenu.talk_mode) {
1178 case SHOP_TALK_NONE:
1179 case SHOP_TALK_GOODBYE:
1180 ShopMenu.step_count = 0;
1181 break;
1182 default:
1183 if (ShopMenu.ready != 0) {
1184 ShopMenu.step_count++;
1185 }
1186
1187 break;
1188 }
1189}
1190
1198static int ShopPersonReadStart(int shop_kind, int shop_no) {
1199 char file_name[76];
1200 int size;
1201 u_long128 *buffer;
1202
1203 ItemShopGetPacFileName(shop_kind, shop_no, file_name);
1204 buffer = (u_long128 *) (ShopCashBuffer.base + ShopCashBuffer.used * 16);
1205 buffer = MenuCalcBufAlignment(buffer);
1206 StartReadBG();
1207
1208 if (!LoadFileBG(file_name, buffer, &size)) {
1209#ifdef PAL
1210 printf("load is failed\n");
1211#endif
1212 return 0;
1213 }
1214
1215 ReadBG();
1216 ShopMenu.person_state = 0;
1217 return 1;
1218}
1219
1223static void ShopMasterVectorSet(int mode);
1224
1228static inline void GetRestSize(int &rest, int total, int used) {
1229 rest = total - used;
1230}
1231
1239static int ShopPersonBuild(int shop_kind, int shop_no) {
1240 char name[64];
1241 int size;
1242
1243 if (ShopMenu.person_state == 0 && ReadBGSync() != 0) {
1244 return 0;
1245 }
1246
1247 ItemShopGetImgFileName(shop_kind, shop_no, name);
1248 BG_READ_INFO *file = GetReadBGFile(0);
1249 u_int *pack = (u_int *) file->buffer;
1250 u_char *model_area = (u_char *) pack + ((file->size >> 4) + 1) * 16;
1251 LOADTEXTURE_INFO2 texture[3] = {
1252 {"#frame_menushop_model#640#" SCREEN_HEIGHT_STR "#4", 0, 0},
1253 {NULL, 0, 0},
1254 {NULL, 0, 0},
1255 };
1256 texture[0].block_no = ShopMenu.person_tex_block;
1257 texture[1].block_no = ShopMenu.person_tex_block;
1258 texture[1].name = (char *) GetPackFile(pack, name, &size);
1259 TexManager.DeleteTextureBlock(ShopMenu.person_tex_block);
1260 TexManager.LoadTextureBlockEX(-1, texture);
1261 GetRestSize(size, EdMenuBuffer.limit, ShopCashBuffer.limit);
1262 int limit = size;
1263 ShopCashBuffer2.base = model_area;
1264 ShopCashBuffer2.limit = limit;
1265 ShopCashBuffer2.used = 0;
1266 MenuCharaFrame.Initialize();
1267 MenuCharaFrame.LoadPackData(pack, "info.cfg", &ShopCashBuffer2, &ShopCashBuffer2, NULL);
1268 sceVu0FVECTOR position = {-7.0f, -17.0f, 0.0f, 1.0f};
1269 MenuCharaFrame.SetPosition(position);
1270 ShopPolySetInit(shop_kind, shop_no);
1271
1272 if (MenuCharaFrame.frame == NULL) {
1273 printf("Frame is NULL\n");
1274 return 0;
1275 }
1276
1277 ShopMenu.motion = 3;
1278 MenuCharaFrame.SetMotion(ShopMenu.motion, 0);
1279 SetItemShopTalkMode(SHOP_TALK_GREETING, SHOP_MSG_TALKING);
1280 ShopMenu.idle_count = 0;
1281 ShopMenu.msg_no = 0;
1282 ShopMasterVectorSet(0);
1283 ShopMenu.draw_delay = 0;
1284 return 2;
1285}
1286
1294static void LocalShopPersonDraw() {
1295 float ref[4] = {0.0f, 0.0f, -30.0f, 1.0f};
1296 float pos[4] = {0.0f, 0.0f, 30.0f, 1.0f};
1297
1298 MenuCamera.SetRef(ref);
1299 MenuCamera.SetPos(pos);
1300 ShopMasterVectorSet(0);
1301 MenuCharaFrame.Step();
1302
1303 if (ShopMenu.draw_delay < 4) {
1304 ShopMenu.draw_delay++;
1305 } else {
1306 MenuCharaFrame.Draw();
1307 }
1308}
1309
1317static void ShopPersonDraw(int shop_no) {
1318 MenuTextureReload(ShopMenu.person_tex_block);
1319 MenuPolygonDraw(0x80, LocalShopPersonDraw);
1320}
1321
1330static void ShopMasterVectorSet(int mode) {
1331 float camera_pos[4];
1332 float pos[4];
1333 float rotation[4];
1334 float offset[4];
1335 float angle;
1336
1337 switch (mode) {
1338 case 0:
1339 MenuCamera.GetPos(camera_pos);
1340 break;
1341 case 1:
1342 break;
1343 }
1344
1345 sceVu0CopyVector(pos, MenuCharaFrame.pos);
1346 MenuCharaFrame.GetRotation(rotation);
1347 sceVu0SubVector(offset, pos, camera_pos);
1348 angle = atan2f(-offset[0], -offset[2]);
1349 rotation[1] = AngleInterpolate(rotation[1], angle, 0.1f, INTERPOLATE_STEP);
1350 MenuCharaFrame.SetRotation(rotation);
1351}
1352
1353void InitChargeShop(int *tex_block, int shop_no, int mode) {
1354 int rows;
1355
1356 if (shop_no >= 100) {
1357 shop_no -= 100;
1358 }
1359
1360 ShopMenuInit(tex_block, shop_no, mode);
1361 ShopMenu.board.cursor = 0;
1362 ShopMenu.side = SHOP_SIDE_PERSONAL;
1363 ShopMenu.cursor_x = (ShopMenu.board.cursor % 5) * 0x28 + 0x154;
1364 ShopMenu.cursor_y = 120.0f;
1365 ShopStockPt = SaveData->GetStockItem();
1366 rows = ChargeShopMax[0] / 5;
1367 ShopMenu.stock_top_row = 0;
1368 ShopMenu.stock_y = 0x8A - ShopMenu.stock_top_row * 0x28;
1369 ShopMenu.stock_scroll = 142.0f + 114.0f * ShopMenu.stock_top_row / rows;
1370 ShopMenu.stock_row_offset = 0;
1371 GetMainMenuRightHelpWinLangOffset(ShopHelpWinPos[0], ShopHelpWinPos[1], ShopHelpWinW, ShopHelpWinH);
1372}
1373
1374void ChargeShopLimmitCheck() {
1375 int max = ChargeShopMax[ShopMenu.board.page];
1376 int top = ShopMenu.stock_top_row;
1377 int rows = max / 5;
1378 int last_top = rows - 4;
1379
1380 if (last_top < 0) {
1381 last_top = 0;
1382 }
1383
1384 int cursor = ShopMenu.board.cursor;
1385
1386 if (max - 1 < cursor && ShopMenu.side == SHOP_SIDE_STOCK) {
1387 while (ShopMenu.board.cursor >= max) {
1388 ShopMenu.board.cursor -= 5;
1389 }
1390
1391 ShopMenu.stock_top_row = ShopMenu.board.cursor / 5 - 3;
1392
1393 if (ShopMenu.stock_top_row < 0) {
1394 ShopMenu.stock_top_row = 0;
1395 }
1396
1397 ShopMenu.stock_y = 0x8A - ShopMenu.stock_top_row * 0x28;
1398
1399 if (rows <= 0) {
1400 rows = 4;
1401 }
1402
1403 ShopMenu.stock_scroll = 142.0f + 114.0f * ShopMenu.stock_top_row / rows;
1404 return;
1405 }
1406
1407 if (last_top < top) {
1408 while (last_top < ShopMenu.stock_top_row) {
1409 ShopMenu.stock_top_row--;
1410 }
1411
1412 ShopMenu.stock_y = 0x8A - ShopMenu.stock_top_row * 0x28;
1413 ShopMenu.stock_scroll = 142.0f + 114.0f * ShopMenu.stock_top_row / rows;
1414 }
1415}
1416
1417static void ExitChargeShop() {
1418 ShopMenuExit();
1419}
1420
1421int ChargeShopLoop() {
1422 int done;
1423
1424 ReadBG();
1425 done = ChargeShopKey();
1426 DrawChargeShop();
1427
1428 if (done) {
1429 ExitChargeShop();
1430 }
1431
1432 return done;
1433}
1434
1435static inline void ShopDataMoveClear() {
1436 ShopDataMove.spare = -1;
1437 ShopDataMove.slot_no = -1;
1438 ShopDataMove.icon_no = -1;
1439 ShopDataMove.item_no = -1;
1440 ShopDataMove.pos_y = 0.0f;
1441 ShopDataMove.pos_x = 0.0f;
1442 memset(&ShopDataMove.data, 0, sizeof(WEAPON_HAVE));
1443}
1444
1445static inline void ShopDataMoveFinish() {
1446 if (ShopDataMove.icon_no >= 0) {
1447 ShopDataMove.IconAutoMove(ChargeOrShopFlag, 1);
1448 ShopDataMoveClear();
1449 }
1450}
1451
1452static inline WEAPON_HAVE *ShopWeaponRow(CUserStatus *status, int chara) {
1453 return status->chara_weapons[chara];
1454}
1455
1456int ChargeShopKey() {
1457 int result = 0;
1458 MENU_ITEMDATA record;
1459 MENU_ITEMDATA stock;
1460 MENU_ITEMDATA weapon;
1461 ATTACH_LIST attach;
1462
1463 if (ShopMenu.ready == 0) {
1464 if (ReadBGSync() == 0) {
1465 ShopTextureLoadFix();
1466#ifdef PAL
1467 printf("Model Read Start\n");
1468#endif
1469 ShopPersonReadStart(SHOP_KIND_CHARGE, ShopMenu.shop_no);
1470 }
1471 } else {
1472 switch (ShopMenu.talk_mode) {
1473 case SHOP_TALK_FADE_IN:
1474 ShopMenu.alpha += 8;
1475
1476 if (ShopMenu.alpha >= 0x80) {
1477 ShopMenu.alpha = 0x80;
1478 }
1479
1480 if (ShopMenu.step_count > 20 && ShopMenu.ready != 0 && ShopMenu.alpha >= 0x80) {
1481 ShopMenu.talk_mode = SHOP_TALK_NONE;
1482 }
1483
1484 break;
1485 case SHOP_TALK_FADE_OUT:
1486 ShopMenu.alpha -= 8;
1487
1488 if (ShopMenu.alpha <= 0) {
1489 ShopMenu.alpha = 0;
1490 }
1491
1492 if (ShopMenu.step_count > 26 && ShopMenu.alpha <= 0) {
1493 result = 1;
1494 }
1495
1496 break;
1497 case SHOP_TALK_GREETING:
1498 CommonMenuMes3.page_arrow = true;
1499
1500 if (GamePad.Down(PAD_DPAD) != 0 || GamePad.AllOn() != 0) {
1501 ShopMenu.talk_mode = SHOP_TALK_NONE;
1502 ComMenuSePlay(MENU_SOUND_REFUSE);
1503 CommonMenuMes3.page_arrow = false;
1504 }
1505
1506 break;
1507 case SHOP_TALK_STOCK_FULL:
1508 CommonMenuMes3.page_arrow = true;
1509
1510 if (GamePad.Down(PAD_DPAD) != 0) {
1511 ShopMenu.talk_mode = SHOP_TALK_NONE;
1512 ComMenuSePlay(MENU_SOUND_REFUSE);
1513 CommonMenuMes3.page_arrow = false;
1514 }
1515 case SHOP_TALK_CANNOT_CHARGE:
1516 case SHOP_TALK_INVENTORY_OVERFLOW:
1517 CommonMenuMes3.page_arrow = true;
1518
1519 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
1520 SetItemShopTalkMode(SHOP_TALK_NONE, SHOP_MSG_IDLE);
1521 ComMenuSePlay(MENU_SOUND_REFUSE);
1522 CommonMenuMes3.page_arrow = false;
1523 }
1524
1525 break;
1526 case SHOP_TALK_CHARGE_PUT_PROMPT:
1527 if (GamePad.Down(PAD_CIRCLE) != 0) {
1528 ShopMenu.talk_mode = SHOP_TALK_NONE;
1529 ComMenuSePlay(MENU_SOUND_REFUSE);
1530 } else if (GamePad.Down(PAD_TRIANGLE | PAD_CROSS) != 0) {
1531 ShopDataMoveFinish();
1532 int space = ShopStockPt->GetNowModeSpace(ShopMenu.board.page);
1533 int icon = space - ShopMenu.stock_top_row * 5;
1534 s16 cursor = ShopMenu.board.cursor;
1535 int item_no;
1536
1537 switch (ShopMenu.board.page) {
1538 case BOARD_PAGE_ITEM: {
1539 ITEM_PACK *pack = &ShopUserStatusPt->item_pack;
1540 item_no = pack->item[cursor];
1541 record.volume = pack->item_vol[cursor];
1542 printf("charge vol = %d\n", record.volume);
1543 pack->item[cursor] = -1;
1544 pack->item_vol[cursor] = 0;
1545 break;
1546 }
1547 case BOARD_PAGE_ATTACH: {
1548 ATTACH_LIST *list = &((ATTACH_LIST *) ShopUserStatusPt->consumable_items)[cursor];
1549 item_no = list->item_no;
1550 memcpy(&record, list, sizeof(ATTACH_LIST));
1551 memset(list, 0, sizeof(ATTACH_LIST));
1552 break;
1553 }
1554 case BOARD_PAGE_WEAPON: {
1555 WEAPON_HAVE *have = &ShopWeaponRow(ShopUserStatusPt, cursor / 10)[cursor % 10];
1556 item_no = have->item_no;
1557 memcpy(&record, have, sizeof(WEAPON_HAVE));
1558 memset(have, 0, sizeof(WEAPON_HAVE));
1559 break;
1560 }
1561 }
1562
1563 int row = ShopMenu.board.cursor / 5 - ShopMenu.board.top_row;
1564 int x = ShopMenu.board.cursor % 5 * 0x28 + 0x156;
1565 int y = row * 0x28 + 0x94;
1566 ShopDataMove.IconMoveTarSet(space, icon, item_no, &record, x, y, 1);
1567
1568 if (icon < 0 || icon >= 20) {
1569 ShopDataMove.IconAutoMove(ChargeOrShopFlag, 1);
1570 ShopDataMoveClear();
1571 }
1572
1573 SetItemShopTalkMode(SHOP_TALK_NONE, SHOP_MSG_IDLE);
1574 ComMenuSePlay(MENU_SOUND_CONFIRM);
1575 }
1576
1577 break;
1578 case SHOP_TALK_CHARGE_TAKE_PROMPT:
1579 if (GamePad.Down(PAD_TRIANGLE | PAD_CROSS) != 0) {
1580 int page;
1581 s16 stock_item;
1582 s16 volume;
1583 ShopDataMoveFinish();
1584 stock_item = 0;
1585 memset(&stock, 0, sizeof(stock));
1586
1587 switch (ShopMenu.board.page) {
1588 case BOARD_PAGE_ITEM:
1589 volume = 0;
1590 ShopStockPt->SetItemToPos(ShopMenu.board.cursor, &stock_item, &volume);
1591 stock.volume = volume;
1592 break;
1593 case BOARD_PAGE_ATTACH:
1594 ShopStockPt->SetAttachToPos(ShopMenu.board.cursor, &stock.attach);
1595 stock_item = stock.attach.item_no;
1596 break;
1597 case BOARD_PAGE_WEAPON:
1598 ShopStockPt->SetWepToPos(ShopMenu.board.cursor, &stock.weapon);
1599 stock_item = stock.weapon.item_no;
1600 break;
1601 }
1602
1603 int space = GetBoardSpace(stock_item, &page);
1604 int icon = space - ShopMenu.board.top_row * 5;
1605 int row = ShopMenu.board.cursor / 5 - ShopMenu.stock_top_row;
1606 int x = ShopMenu.board.cursor % 5 * 0x28 + 0x34;
1607 int y = row * 0x28 + 0x94;
1608 ShopDataMove.IconMoveTarSet(space, icon, stock_item, &stock, x, y, 0);
1609
1610 if (icon < 0 || icon >= 20) {
1611 ShopDataMove.IconAutoMove(ChargeOrShopFlag, 1);
1612 ShopDataMoveClear();
1613 }
1614
1615 SetItemShopTalkMode(SHOP_TALK_NONE, SHOP_MSG_IDLE);
1616 ComMenuSePlay(MENU_SOUND_CONFIRM);
1617 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
1618 ShopMenu.talk_mode = SHOP_TALK_NONE;
1619 ComMenuSePlay(MENU_SOUND_REFUSE);
1620 }
1621
1622 break;
1623 case SHOP_TALK_GOODBYE:
1624 CommonMenuMes3.page_arrow = true;
1625
1626 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
1627 ShopMenu.talk_mode = SHOP_TALK_FADE_OUT;
1628 ShopMenu.step_count = 0;
1629 CommonMenuMes3.page_arrow = false;
1630 ComMenuSePlay(MENU_SOUND_CONFIRM);
1631 }
1632
1633 break;
1634 case SHOP_TALK_LEAVE_PROMPT:
1635 CommonMenuMes3.page_arrow = false;
1636
1637 if (GamePad.Down(PAD_CROSS) != 0) {
1638 SetItemShopTalkMode(SHOP_TALK_NONE, SHOP_MSG_IDLE);
1639 ComMenuSePlay(MENU_SOUND_CONFIRM);
1640 CommonMenuMes3.page_arrow = false;
1641 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
1642 SetItemShopTalkMode(SHOP_TALK_GOODBYE, SHOP_MSG_TALKING);
1643 ComMenuSePlay(MENU_SOUND_REFUSE);
1644 CommonMenuMes3.page_arrow = false;
1645 }
1646
1647 break;
1648 case SHOP_TALK_NONE: {
1649 if (ShopMenu.person_state == 0) {
1650 ShopMenu.person_state = ShopPersonBuild(SHOP_KIND_CHARGE, ShopMenu.shop_no);
1651 }
1652
1653 int page = ShopMenu.board.page;
1654 int cursor = ShopMenu.board.cursor;
1655 int board_exit = 0;
1656
1657 switch (ShopMenu.side) {
1658 case SHOP_SIDE_STOCK:
1659 board_exit = ChargeSelectKey();
1660 break;
1661 case SHOP_SIDE_PERSONAL:
1662 if (ShopHaveItemPt->item_no < ITEM_ATTACH_START) {
1663 BoardModeChangeKey();
1664 PersonalBoardLimmitCheck();
1665 ChargeShopLimmitCheck();
1666 }
1667
1668 board_exit = PersonalBoardKeySub();
1669
1670 if (board_exit == 0 && GamePad.Down(PAD_CROSS) != 0) {
1671 s16 held = ShopHaveItemPt->item_no;
1672 PERSONAL_BOARD *board = &ShopMenu.board;
1673
1674 switch (board->cursor_area) {
1675 case PERSONAL_BOARD_AREA_TRASH: {
1676 if (held < ITEM_ATTACH_START) {
1677 ComMenuSePlay(MENU_SOUND_REFUSE);
1678 } else {
1679 if (IsEnableTrushThrow(held) != 0) {
1680 board->trash_anim = 1;
1681 board->trash_frame = 0;
1682 InitAllHaveData();
1683 }
1684
1685 ComMenuSePlay(MENU_SOUND_REFUSE);
1686 }
1687
1688 break;
1689 }
1690 case PERSONAL_BOARD_AREA_CELLS:
1691 if (PersonalBoardItemGetorSwap(ShopMenu.board.cursor) != 0) {
1692 if (ShopHaveItemPt->item_no >= ITEM_ATTACH_START) {
1693 ShopHaveItemPt->slot_state = SHOP_SLOT_SHOP_GOOD;
1694 } else {
1695 InitAllHaveData();
1696 ShopMenu.board.held_equipped_slot = -1;
1697 }
1698
1699 ComMenuSePlay(MENU_SOUND_CONFIRM);
1700 } else {
1701 ComMenuSePlay(MENU_SOUND_REFUSE);
1702 }
1703
1704 break;
1705 }
1706 } else if (board_exit == 0 && GamePad.Down(PAD_SQUARE) != 0) {
1707 switch (ShopMenu.board.page) {
1708 case BOARD_PAGE_ITEM:
1709 SeitonItemBoard(&ShopUserStatusPt->item_pack);
1710 SetMenuTrushMark(&ShopUserStatusPt->item_pack);
1711 break;
1712 case BOARD_PAGE_ATTACH:
1713 SeitonAttachBoard((ATTACH_LIST *) ShopUserStatusPt->consumable_items);
1714 break;
1715 }
1716
1717 ComMenuSePlay(MENU_SOUND_CONFIRM);
1718 } else if (board_exit == 0 && GamePad.Down(PAD_TRIANGLE) != 0) {
1719 int enable = true;
1720
1721 if (ShopMenu.board.cursor_area == PERSONAL_BOARD_AREA_TRASH) {
1722 ComMenuSePlay(MENU_SOUND_REFUSE);
1723 } else if (ShopHaveItemPt->item_no >= ITEM_ATTACH_START) {
1724 ComMenuSePlay(MENU_SOUND_REFUSE);
1725 } else {
1726 s16 target = SearchBoardNowPosItemExist(ShopMenu.board.page, ShopMenu.board.cursor);
1727
1728 switch (ShopMenu.board.page) {
1729 case BOARD_PAGE_ITEM:
1730 case BOARD_PAGE_ATTACH:
1731 break;
1732 case BOARD_PAGE_WEAPON: {
1733 int owner = WhoIsWeaponEquip(target);
1734
1735 if (target < ITEM_WEAPON_START) {
1736 ComMenuSePlay(MENU_SOUND_REFUSE);
1737 } else {
1738 if (owner == IsDefaultWeapon(target)) {
1739 SetItemShopTalkMode(SHOP_TALK_CANNOT_CHARGE, SHOP_MSG_TALKING);
1740 enable = false;
1741 }
1742
1743 s8 slot = ShopUserStatusPt->equipped_weapon_slot[owner];
1744
1745 if (ShopMenu.board.cursor % 10 == slot) {
1746 SetItemShopTalkMode(SHOP_TALK_CANNOT_CHARGE, SHOP_MSG_TALKING);
1747 enable = false;
1748 }
1749 }
1750
1751 break;
1752 }
1753 }
1754
1755 if (enable != 0) {
1756 enable = IsEnableCharge(target);
1757
1758 if (enable == 0) {
1759 SetItemShopTalkMode(SHOP_TALK_CANNOT_CHARGE, SHOP_MSG_TALKING);
1760 }
1761 }
1762
1763 if (ShopStockPt->GetNowModeSpace(ShopMenu.board.page) < 0) {
1764 enable = false;
1765 SetItemShopTalkMode(SHOP_TALK_STOCK_FULL, SHOP_MSG_TALKING);
1766 }
1767
1768 if (target < ITEM_ATTACH_START) {
1769 SetItemShopTalkMode(SHOP_TALK_NONE, SHOP_MSG_IDLE);
1770 enable = false;
1771 }
1772
1773 if (enable != 0) {
1774 ShopMenu.talk_mode = SHOP_TALK_CHARGE_PUT_PROMPT;
1775 ComMenuSePlay(MENU_SOUND_CONFIRM);
1776 } else {
1777 ComMenuSePlay(MENU_SOUND_REFUSE);
1778 }
1779 }
1780 }
1781
1782 break;
1783 }
1784
1785 if (GamePad.Down(PAD_CIRCLE) != 0) {
1786 ComMenuSePlay(MENU_SOUND_REFUSE);
1787
1788 if (ShopHaveItemPt->item_no < ITEM_ATTACH_START) {
1789 SetItemShopTalkMode(SHOP_TALK_LEAVE_PROMPT, SHOP_MSG_TALKING);
1790 } else {
1791 switch (ShopHaveItemPt->slot_state) {
1792 case SHOP_SLOT_SHOP_GOOD:
1793 PersonalBoardItemCancel();
1794 break;
1795 case SHOP_SLOT_EMPTY:
1796 switch (ShopHaveItemPt->from_page) {
1797 case BOARD_PAGE_ITEM:
1798 ShopStockPt->SetItemToPos(ShopHaveItemPt->from_slot, &ShopHaveItemPt->item_no, &ShopHaveItemPt->volume);
1799 break;
1800 case BOARD_PAGE_WEAPON: {
1801 ShopStockPt->GetWeaponInfo(ShopHaveItemPt->from_slot, &weapon.weapon);
1802 s16 stock_item = weapon.weapon.item_no;
1803 ShopStockPt->SetWepToPos(ShopHaveItemPt->from_slot, ShopHaveWepPt);
1804 ShopHaveItemPt->item_no = stock_item;
1805 break;
1806 }
1807 case BOARD_PAGE_ATTACH: {
1808 ShopStockPt->GetAttachInfo(ShopHaveItemPt->from_slot, &attach);
1809 s16 stock_item = attach.item_no;
1810 ShopStockPt->SetAttachToPos(ShopHaveItemPt->from_slot, ShopHaveAttachPt);
1811 ShopHaveItemPt->item_no = stock_item;
1812 break;
1813 }
1814 }
1815
1816 if (ShopHaveItemPt->item_no < ITEM_ATTACH_START) {
1817 InitAllHaveData();
1818 }
1819
1820 break;
1821 }
1822 }
1823 }
1824
1825#ifdef PAL
1826 // Debug shortcut: raises or lowers the party's Gilda.
1827 if (DebugMode) {
1828 int step;
1829 int money = ShopUserStatusPt->money;
1830
1831 step = 0;
1832
1833 if (GamePad.On2(PAD_UP) && money < 9999) {
1834 step++;
1835 }
1836
1837 if (GamePad.On2(PAD_DOWN) && 0 < money) {
1838 step--;
1839 }
1840
1841 CUserStatus *status = ShopUserStatusPt;
1842 int total = status->money + step;
1843
1844 if (total >= 0xFFFF) {
1845 status->money = 0xFFFF;
1846 } else {
1847 status->money = total;
1848 }
1849 }
1850
1851#endif
1852 switch (board_exit) {
1853 case 0:
1854 break;
1855 case 1:
1856 ShopMenu.side = SHOP_SIDE_STOCK;
1857 ShopMenu.board.cursor = (ShopMenu.stock_top_row + (ShopMenu.board.cursor / 5 - ShopMenu.board.top_row)) * 5 + 4;
1858 break;
1859 }
1860
1861 if (cursor != ShopMenu.board.cursor || page != ShopMenu.board.page) {
1862 int max = ChargeShopMax[ShopMenu.board.page];
1863 int top = ShopMenu.stock_top_row;
1864 int rows = max / 5;
1865 int last_top = rows - 4;
1866
1867 if (last_top < 0) {
1868 last_top = 0;
1869 }
1870
1871 if (last_top < top) {
1872 ShopMenu.stock_top_row = ShopMenu.board.cursor / 5 - 3;
1873
1874 if (ShopMenu.stock_top_row < 0) {
1875 ShopMenu.stock_top_row = 0;
1876 }
1877
1878 ShopMenu.stock_y = 0x8A - ShopMenu.stock_top_row * 0x28;
1879
1880 if (rows <= 0) {
1881 rows = 4;
1882 }
1883
1884 ShopMenu.stock_scroll = 142.0f + 114.0f * ShopMenu.stock_top_row / rows;
1885 }
1886
1887 ComMenuSePlay(MENU_SOUND_CURSOR);
1888 }
1889
1890 break;
1891 }
1892 }
1893
1894 int mes_no = 0;
1895 int item = 0;
1896 int value = 0;
1897 int name_mes = -1;
1898 int cursor = ShopMenu.board.cursor;
1899
1900 if (ShopHaveItemPt->item_no >= ITEM_ATTACH_START) {
1901 item = ShopHaveItemPt->item_no;
1902 COM_ITEM_INFO *info = GetCommonItemInfo(item);
1903 mes_no = info != NULL ? info->msg + 500 : mes_no;
1904 value = GetAttachVolumeForMsg(ShopHaveAttachPt);
1905
1906 if (ShopHaveItemPt->item_no == ITEM_ATTACH_SYNTHESIS_SPHERE) {
1907 name_mes = ShopHaveAttachPt->sphere_weapon_no + 100;
1908 }
1909 }
1910
1911 switch (ShopMenu.side) {
1912 case SHOP_SIDE_STOCK:
1913 switch (ShopMenu.board.page) {
1914 case BOARD_PAGE_ITEM:
1915 item = ShopStockPt->dungeon_items[cursor];
1916 break;
1917 case BOARD_PAGE_WEAPON: {
1918 COM_ITEM_INFO *info = GetCommonItemInfo(ShopStockPt->weapons[cursor].item_no);
1919
1920 if (info != NULL) {
1921 item = info->msg;
1922 } else {
1923 item = -1;
1924 }
1925
1926 if (item >= ITEM_WEAPON_START) {
1927 value = ShopStockPt->weapons[cursor].level;
1928 }
1929
1930 break;
1931 }
1932 case BOARD_PAGE_ATTACH:
1933 item = ShopStockPt->attachments[cursor].item_no;
1934
1935 if (item >= ITEM_ATTACH_START) {
1936 mes_no = item + 500;
1937 value = GetAttachVolumeForMsg(&ShopStockPt->attachments[cursor]);
1938
1939 if (item == ITEM_ATTACH_SYNTHESIS_SPHERE) {
1940 name_mes = ShopStockPt->attachments[cursor].sphere_weapon_no + 100;
1941 }
1942 }
1943
1944 break;
1945 }
1946
1947 break;
1948 case SHOP_SIDE_PERSONAL:
1949 switch (ShopMenu.board.page) {
1950 case BOARD_PAGE_ITEM: {
1951 ITEM_PACK *pack = &ShopUserStatusPt->item_pack;
1952 item = pack->item[cursor];
1953
1954 if (item >= ITEM_DUNGEON_START) {
1955 mes_no = item + 500;
1956 }
1957
1958 break;
1959 }
1960 case BOARD_PAGE_WEAPON: {
1961 CUserStatus *status = ShopUserStatusPt;
1962 WEAPON_HAVE *row = status->chara_weapons[cursor / 10];
1963 WEAPON_HAVE *have = &row[cursor % 10];
1964 COM_ITEM_INFO *info = GetCommonItemInfo(have->item_no);
1965
1966 if (info != NULL) {
1967 item = info->msg;
1968 } else {
1969 item = -1;
1970 }
1971
1972 if (item >= 0) {
1973 mes_no = item + 500;
1974 value = have->level;
1975 }
1976
1977 break;
1978 }
1979 case BOARD_PAGE_ATTACH: {
1980 ATTACH_LIST *list = &((ATTACH_LIST *) ShopUserStatusPt->consumable_items)[cursor];
1981 item = list->item_no;
1982
1983 if (item >= ITEM_ATTACH_START) {
1984 mes_no = item + 500;
1985 value = GetAttachVolumeForMsg(list);
1986
1987 if (item == ITEM_ATTACH_SYNTHESIS_SPHERE) {
1988 name_mes = list->sphere_weapon_no + 100;
1989 }
1990 }
1991
1992 break;
1993 }
1994 }
1995
1996 if (ShopMenu.board.cursor_area == PERSONAL_BOARD_AREA_TRASH) {
1997 mes_no = 1000;
1998 }
1999
2000 break;
2001 }
2002
2003 if (item > 0) {
2004 mes_no = item + 500;
2005 }
2006
2007 if (CommonMenuMes2.mes_made != mes_no || (name_mes > 0 && CommonMenuMes2.mes_no[0] != name_mes) || CommonMenuMes2.value != value) {
2008 CommonMenuMes2.value_signed = true;
2009 CommonMenuMes2.value = value;
2010
2011 if (name_mes > 0) {
2012 CommonMenuMes2.mes_no[0] = name_mes;
2013 }
2014
2015 if (mes_no <= 500) {
2016 mes_no = 0;
2017 }
2018
2019 printf("msgno = %d\n", mes_no);
2020 CommonMenuMes2.mes_made = -1;
2021 CommonMenuMes2.MakeMesWin(mes_no);
2022 }
2023 }
2024
2025 return result;
2026}
2027
2035static int ChargeSelectKey() {
2036 if (ShopHaveItemPt->item_no < ITEM_ATTACH_START && BoardModeChangeKey()) {
2037 PersonalBoardLimmitCheck();
2038 ChargeShopLimmitCheck();
2039 }
2040
2041 int count = ChargeShopMax[ShopMenu.board.page];
2042
2043 if (GamePad.Down(PAD_UP)) {
2044 ShopMenu.board.cursor -= 5;
2045
2046 if (ShopMenu.board.cursor < 0) {
2047 ShopMenu.board.cursor += 5;
2048 }
2049
2050 if (ShopMenu.board.cursor / 5 < ShopMenu.stock_top_row) {
2051 ShopMenu.stock_top_row--;
2052 }
2053 }
2054
2055 if (GamePad.Down(PAD_DOWN)) {
2056 if (ShopMenu.board.cursor < count - 5) {
2057 ShopMenu.board.cursor += 5;
2058 }
2059
2060 if (ShopMenu.stock_top_row + 3 < ShopMenu.board.cursor / 5) {
2061 ShopMenu.stock_top_row++;
2062 }
2063 }
2064
2065 if (GamePad.Down(PAD_LEFT) && ShopMenu.board.cursor % 5 != 0) {
2066 ShopMenu.board.cursor--;
2067 }
2068
2069 if (GamePad.Down(PAD_RIGHT)) {
2070 if (ShopMenu.board.cursor % 5 == 4) {
2071 ShopMenu.side = SHOP_SIDE_PERSONAL;
2072 ShopMenu.board.cursor = (ShopMenu.board.top_row + (ShopMenu.board.cursor / 5 - ShopMenu.stock_top_row)) * 5;
2073 } else {
2074 ShopMenu.board.cursor++;
2075 }
2076 }
2077
2078 switch (ShopMenu.side) {
2079 case SHOP_SIDE_STOCK:
2080 int se = 2;
2081 IHAVEITEM saved;
2082 memcpy(&saved, ShopHaveItemPt, sizeof(IHAVEITEM));
2083
2084 if (GamePad.Down(PAD_CROSS)) {
2085 // Put the held item into the stock slot under the cursor.
2086 if (ShopHaveItemPt->item_no >= ITEM_ATTACH_START && !IsEnableCharge(ShopHaveItemPt->item_no)) {
2087 ComMenuSePlay(MENU_SOUND_REFUSE);
2088 SetItemShopTalkMode(SHOP_TALK_CANNOT_CHARGE, SHOP_MSG_TALKING);
2089 return 0;
2090 }
2091
2092 int mode = ShopMenu.board.page;
2093 int kind = WhatIsKindofItem(ShopHaveItemPt->item_no);
2094
2095 if (mode != kind && kind != BOARD_PAGE_NONE) {
2096 se = 2;
2097 } else {
2098 switch (mode) {
2099 case BOARD_PAGE_ITEM:
2100 ShopStockPt->SetItemToPos(ShopMenu.board.cursor, &ShopHaveItemPt->item_no, &ShopHaveItemPt->volume);
2101 break;
2102 case BOARD_PAGE_WEAPON:
2103 ShopStockPt->SetWepToPos(ShopMenu.board.cursor, ShopHaveWepPt);
2104
2105 if (ShopHaveWepPt->item_no < ITEM_ATTACH_START) {
2106 ShopHaveItemPt->item_no = -1;
2107 InitHaveWep(ShopHaveWepPt);
2108 ShopMenu.board.held_equipped_slot = -1;
2109 } else {
2110 ShopHaveItemPt->item_no = ShopHaveWepPt->item_no;
2111 }
2112
2113 break;
2114 case BOARD_PAGE_ATTACH:
2115 ShopStockPt->SetAttachToPos(ShopMenu.board.cursor, ShopHaveAttachPt);
2116
2117 if (ShopHaveAttachPt->item_no < ITEM_ATTACH_START) {
2118 ShopHaveItemPt->item_no = -1;
2119 InitHaveAttach(ShopHaveAttachPt);
2120 ShopMenu.board.held_equipped_slot = -1;
2121 } else {
2122 ShopHaveItemPt->item_no = ShopHaveAttachPt->item_no;
2123 }
2124
2125 break;
2126 }
2127
2128 ShopHaveItemPt->slot_state = SHOP_SLOT_EMPTY;
2129 }
2130
2131 if (ShopHaveItemPt->item_no < ITEM_ATTACH_START) {
2132 InitAllHaveData();
2133 } else {
2134 ShopHaveItemPt->slot_state = SHOP_SLOT_EMPTY;
2135 ShopHaveItemPt->from_page = ShopMenu.board.page;
2136 ShopHaveItemPt->from_slot = ShopMenu.board.cursor;
2137 se = 1;
2138 }
2139
2140 if (memcmp(&saved, ShopHaveItemPt, sizeof(IHAVEITEM)) != 0 || se != 2) {
2141 ComMenuSePlay(MENU_SOUND_CONFIRM);
2142 } else {
2143 ComMenuSePlay(MENU_SOUND_REFUSE);
2144 }
2145 } else if (GamePad.Down(PAD_TRIANGLE)) {
2146 // Check whether the good under the cursor can be taken for charging.
2147 if (ShopHaveItemPt->item_no >= ITEM_ATTACH_START) {
2148 ComMenuSePlay(MENU_SOUND_REFUSE);
2149 return 0;
2150 }
2151
2152 int ok = 1;
2153 ATTACH_LIST attach;
2154 WEAPON_HAVE weapon;
2155 int kind;
2156 int full;
2157 s16 item;
2158 s16 volume;
2159
2160 switch (ShopMenu.board.page) {
2161 case BOARD_PAGE_ITEM:
2162 ShopStockPt->GetItemInfo(ShopMenu.board.cursor, &item, &volume);
2163 break;
2164 case BOARD_PAGE_ATTACH:
2165 ShopStockPt->GetAttachInfo(ShopMenu.board.cursor, &attach);
2166 item = attach.item_no;
2167 break;
2168 case BOARD_PAGE_WEAPON:
2169 ShopStockPt->GetWeaponInfo(ShopMenu.board.cursor, &weapon);
2170 item = weapon.item_no;
2171 break;
2172 }
2173
2174 GetBoardSpace(item, &kind);
2175 full = 0;
2176 int used = 0;
2177 int max = 0;
2178 GetNowModeMaxNum(ShopMenu.board.page, &full);
2179
2180 switch (kind) {
2181 case BOARD_PAGE_ITEM: {
2182 ITEM_PACK *pack = ShopUserItemPack(ShopUserStatusPt);
2183
2184 max = pack->num;
2185
2186 for (int i = 0; i < 3; i++) {
2187 if (pack->quick_item_slot[i] >= ITEM_DUNGEON_START) {
2188 used += pack->quick_item_qty[i];
2189 }
2190 }
2191
2192 for (int i = 0; i < max; i++) {
2193 if (pack->item[i] >= ITEM_DUNGEON_START) {
2194 used++;
2195 }
2196 }
2197
2198 break;
2199 }
2200 case BOARD_PAGE_WEAPON: {
2201 int i;
2202 max = 10;
2203 int chara_no = WhoIsWeaponEquip(item);
2204 CUserStatus *status = ShopUserStatusPt;
2205 WEAPON_HAVE *weapons = status->chara_weapons[chara_no];
2206
2207 for (i = 0; i < 10; i++) {
2208 if (weapons[i].item_no >= ITEM_WEAPON_START) {
2209 used++;
2210 }
2211 }
2212
2213 break;
2214 }
2215 case BOARD_PAGE_ATTACH: {
2216 int i;
2217 max = 40;
2218 DNG_CONSUMABLE *attachments = ShopUserStatusPt->consumable_items;
2219
2220 for (i = 0; i < 40; i++) {
2221 if (attachments[i].id >= ITEM_ATTACH_START) {
2222 used++;
2223 }
2224 }
2225
2226 break;
2227 }
2228 }
2229
2230 if (ShopDataMove.item_no > 0) {
2231 used++;
2232 }
2233
2234 if (used >= max) {
2235 full = 1;
2236 }
2237
2238 if (full && item >= ITEM_ATTACH_START) {
2239 ok = 0;
2240 SetItemShopTalkMode(SHOP_TALK_INVENTORY_OVERFLOW, SHOP_MSG_TALKING);
2241 }
2242
2243 if (item < ITEM_ATTACH_START) {
2244 ok = 0;
2245 SetItemShopTalkMode(SHOP_TALK_NONE, SHOP_MSG_IDLE);
2246 }
2247
2248 if (ok) {
2249 ShopMenu.talk_mode = SHOP_TALK_CHARGE_TAKE_PROMPT;
2250 ComMenuSePlay(MENU_SOUND_CONFIRM);
2251 } else {
2252 ComMenuSePlay(MENU_SOUND_REFUSE);
2253 }
2254 } else if (GamePad.Down(PAD_SQUARE)) {
2255 switch (ShopMenu.board.page) {
2256 case BOARD_PAGE_ITEM:
2257 ShopStockPt->SeitonItem();
2258 break;
2259 case BOARD_PAGE_WEAPON:
2260 break;
2261 case BOARD_PAGE_ATTACH:
2262 ShopStockPt->SeitonAttach();
2263 break;
2264 }
2265
2266 ComMenuSePlay(MENU_SOUND_CONFIRM);
2267 }
2268
2269 break;
2270 }
2271
2272 return 0;
2273}
2274
2278static void ShopModelMsgFunc(int shop_kind);
2279
2280void DrawChargeShop() {
2281 int text_x;
2282 int text_y;
2283
2284 setbilinear(0);
2285 MenuWorldTrans(&MenuCamera);
2286 int bright = 0x40;
2287
2288 switch (ShopMenu.talk_mode) {
2289 case SHOP_TALK_FADE_IN:
2290 bright = 0x80 - ShopMenu.step_count * 3;
2291 break;
2292 case SHOP_TALK_FADE_OUT:
2293 bright = ShopMenu.step_count * 3 + 0x40;
2294 break;
2295 }
2296
2297 if (bright < 0x40) {
2298 bright = 0x40;
2299 }
2300
2301 if (bright > 0x80) {
2302 bright = 0x80;
2303 }
2304
2305 FrameImageDraw(bright, 0x80);
2306
2307 if (ShopMenu.ready != 0) {
2308 int cur_x;
2309 int top_row;
2310 int state;
2311 MenuTextureReload(ShopMenu.tex_block);
2312 DrawPersonalBoard(0x154, 0x84, ShopMenu.board.page, 0x80, 0);
2313 CommonTrushDraw(0x232, 0x118, 0x80);
2314 CommonMoneyBoardDraw(0x163, 0x12C, ShopUserStatusPt->money, 0x80);
2315 ChargeShopBoardDraw(0x32, 0x84, 0x80);
2316
2317 if (ShopHaveItemPt->item_no < ITEM_ATTACH_START) {
2318 ChargeShopLRDraw(0x80);
2319 }
2320
2321 switch (ShopMenu.talk_mode) {
2322 case SHOP_TALK_GOODBYE:
2323 case SHOP_TALK_LEAVE_PROMPT:
2324 break;
2325 default:
2326 switch (ShopMenu.side) {
2327 case SHOP_SIDE_STOCK:
2328 cur_x = 0x22;
2329 top_row = ShopMenu.stock_top_row;
2330 break;
2331 case SHOP_SIDE_PERSONAL:
2332 cur_x = 0x144;
2333 top_row = ShopMenu.board.top_row;
2334 break;
2335 }
2336
2337 if (ShopHaveItemPt->item_no >= ITEM_ATTACH_START) {
2338 state = 2;
2339 } else {
2340 switch (ShopMenu.side) {
2341 case SHOP_SIDE_PERSONAL:
2342 state = SearchBoardNowPosItemExist(ShopMenu.board.page, ShopMenu.board.cursor);
2343
2344 if (state <= 0) {
2345 state = 0;
2346 } else {
2347 state = 1;
2348 }
2349
2350 break;
2351 case SHOP_SIDE_STOCK:
2352 state = ShopStockPt->SearchSpace(ShopMenu.board.cursor, ShopMenu.board.page);
2353
2354 if (state > 0) {
2355 state = 1;
2356 }
2357
2358 break;
2359 }
2360 }
2361
2362 ShopCurDraw(cur_x, 0x90, ShopMenu.board.cursor, top_row, 0, state, 0x80);
2363 break;
2364 }
2365
2366 DrawShopIcon(0x4C, 0x2A, 1, 0x80);
2367 ShopDataMove.IconAutoMoveDraw();
2368 ShopDataMove.IconAutoMove(ChargeOrShopFlag, 0);
2369
2370 if (ShopMenu.talk_mode == SHOP_TALK_CHARGE_PUT_PROMPT || ShopMenu.talk_mode == SHOP_TALK_CHARGE_TAKE_PROMPT) {
2371 int prompt[2] = {0x516, 0x517};
2372
2373 if (CommonMenuMes1.mes_made != prompt[ShopMenu.talk_mode - SHOP_TALK_CHARGE_PUT_PROMPT]) {
2374 CommonMenuMes1.MakeMesWin(prompt[ShopMenu.talk_mode - SHOP_TALK_CHARGE_PUT_PROMPT]);
2375 }
2376
2377 CommonMenuMes1.text_x = 0x14A;
2378 CommonMenuMes1.text_y = 0xBE;
2379
2380 if (ShopMenu.talk_mode == SHOP_TALK_CHARGE_PUT_PROMPT) {
2381 CommonMenuMes1.text_x = 0x96;
2382 }
2383
2384 CommonMenuMes1.stay_frame = true;
2385 CommonMenuMes1.Step();
2386 CommonMenuMes1.DrawMesWin();
2387 } else {
2388 CommonMenuMes1.stay_frame = false;
2389 }
2390
2391 MenuHelpWinDraw((int) ShopHelpWinPos[0], (int) ShopHelpWinPos[1], ShopHelpWinW, ShopHelpWinH, 0x80);
2392 GetMainMenuRightHelpMsgLangOffset(text_x, text_y);
2393 CommonMenuMes2.text_x = (int) (ShopHelpWinPos[0] + text_x);
2394 CommonMenuMes2.text_y = (int) (ShopHelpWinPos[1] + text_y);
2395 }
2396
2397 if (ShopMenu.person_state == 2) {
2398 ShopPersonDraw(ShopMenu.shop_no);
2399 }
2400
2401 if (ShopMenu.ready != 0) {
2402 MenuTextureReload(CommonMenuMes2.tex_block);
2403 CommonMenuMes2.Step();
2404 CommonMenuMes2.DrawMesWin();
2405
2406 if (ShopHaveItemPt->item_no < ITEM_ATTACH_START) {
2407 int mes_no = 0x519;
2408#ifdef PAL
2409 u8 plate_x[7][2] = {
2410 {0xA2, 0xB4},
2411 {0xB4, 0xB4},
2412 {0xB4, 0xB4},
2413 {0x78, 0x78},
2414 {0xAA, 0xB4},
2415 {0xB4, 0xB4},
2416 {0xB4, 0xB4}
2417 };
2418#else
2419 s16 plate_x[7][2] = {
2420 {0xA2, 0xB4},
2421 {0xB4, 0xB4},
2422 {0xB4, 0xB4},
2423 {0xB4, 0xB4},
2424 {0xB4, 0xB4},
2425 {0xB4, 0xB4},
2426 {0xB4, 0xB4}
2427 };
2428#endif
2429 AtoraNameMes.text_x = plate_x[ShopMenu.lang][0];
2430
2431 if (ShopMenu.side == SHOP_SIDE_PERSONAL) {
2432 mes_no = 0x518;
2433 AtoraNameMes.text_x = plate_x[ShopMenu.lang][1];
2434 }
2435
2436 if (AtoraNameMes.mes_made != mes_no) {
2437 AtoraNameMes.MakeMesWin(mes_no);
2438 }
2439
2440 AtoraNameMes.stay_frame = true;
2441 AtoraNameMes.text_y = SCREEN_HEIGHT - 0x5E;
2442 AtoraNameMes.Step();
2443 AtoraNameMes.DrawMesWin();
2444 }
2445 }
2446
2447 ShopModelMsgFunc(SHOP_KIND_CHARGE);
2448 ShopFadeoutDraw();
2449 setbilinear(1);
2450}
2451
2459static void ChargeShopMaxDraw(int max, int x, int y, int alpha) {
2460 int left = x + 0xD2;
2461 int top = y - 0x28;
2462
2463 DrawMenu2DSprite(ShopBoard, CRect_i_(left, top + 1, 0x30, 0x2F), CRect_i_(0x100, 0x90, 0x30, 0x30), alpha);
2464 RECT digits = {0x90, 0xDC, 12, 13};
2465 left = x + 0xF7;
2466 top = y - 0xE;
2467 DrawMenuNumber(max, left, top, ShopBoard, digits, 1, alpha);
2468 left = x + 0xF2;
2469 top = y - 0x22;
2470 int count = 0;
2471 int i;
2472
2473 switch (ShopMenu.board.page) {
2474 case BOARD_PAGE_ITEM:
2475 for (i = 0; i < 60; i++) {
2476 if (ShopStockPt->dungeon_items[i] >= ITEM_DUNGEON_START) {
2477 count++;
2478 }
2479 }
2480
2481 break;
2482 case BOARD_PAGE_WEAPON:
2483 for (i = 0; i < 30; i++) {
2484 if (ShopStockPt->weapons[i].item_no >= ITEM_WEAPON_START) {
2485 count++;
2486 }
2487 }
2488
2489 break;
2490 case BOARD_PAGE_ATTACH:
2491 for (i = 0; i < 30; i++) {
2492 if (ShopStockPt->attachments[i].item_no >= ITEM_ATTACH_START) {
2493 count++;
2494 }
2495 }
2496
2497 break;
2498 }
2499
2500 DrawMenuNumber(count, left, top, ShopBoard, digits, 1, alpha);
2501}
2502
2503void ChargeShopBoardDraw(int x, int y, int alpha) {
2504 s16 items[120];
2505 u8 values[120];
2506 int top = y + 9;
2507 int bottom = y + 0xA9;
2508 int board_y;
2509 int left = x + 0x14;
2510
2511 board_y = y + 6 - ShopMenu.stock_top_row * 0x28;
2512 ShopMenu.stock_y += ((float) board_y - ShopMenu.stock_y) / 4.0f;
2513 board_y = ShopMenu.stock_y;
2514 DrawPerBoardDraw(0, 0x64, left, board_y, top, bottom, ShopBoard, alpha);
2515
2516 int board_mode = ShopMenu.board.page;
2517 int i;
2518
2519 switch (board_mode) {
2520 case BOARD_PAGE_WEAPON:
2521 for (i = 0; i < 30; i++) {
2522 items[i] = ShopStockPt->weapons[i].item_no;
2523 values[i] = 0;
2524 }
2525
2526 break;
2527 case BOARD_PAGE_ITEM:
2528 for (i = 0; i < 60; i++) {
2529 items[i] = ShopStockPt->dungeon_items[i];
2530 values[i] = 0;
2531 }
2532
2533 break;
2534 case BOARD_PAGE_ATTACH:
2535 for (i = 0; i < 30; i++) {
2536 items[i] = ShopStockPt->attachments[i].item_no;
2537
2538 if (items[i] >= ITEM_ATTACH_STAT_START && items[i] < ITEM_ATTACH_GEM_START) {
2539 values[i] = (&ShopStockPt->attachments[i].item_no)[items[i] - ITEM_ATTACH_STAT_START + 4];
2540 } else if (items[i] == ITEM_ATTACH_SYNTHESIS_SPHERE) {
2541 values[i] = ShopStockPt->attachments[i].sphere_weapon_no;
2542 } else {
2543 values[i] = 0;
2544 }
2545 }
2546
2547 break;
2548 }
2549
2550 for (; i < 60; i++) {
2551 items[i] = -1;
2552 values[i] = 0;
2553 }
2554
2555 ShopIconDraw(items, values, 0x80, left + 4, board_y + 6, top, bottom, 0x80);
2556
2557 int tag = 0;
2558
2559 switch (board_mode) {
2560 case BOARD_PAGE_ITEM:
2561 tag += 0xC;
2562 break;
2563 case BOARD_PAGE_WEAPON:
2564 tag += 0xA;
2565 break;
2566 case BOARD_PAGE_ATTACH:
2567 tag = 1;
2568 break;
2569 }
2570
2571 PersonalBoardTagDraw(board_mode, x, y, ShopBoard, tag, alpha);
2572 PersonalBoardDrawWaku(x, y, ShopBoard, alpha);
2573 PersonalBoardScrlBarDraw(ChargeShopMax[board_mode], x, y, ShopMenu.stock_scroll, ShopMenu.stock_top_row, ShopBoard, alpha);
2574 ChargeShopMaxDraw(ChargeShopMax[board_mode], x, y, alpha);
2575}
2576
2584static int CalItemMoney(int item_no, int sell) {
2585 if (item_no < ITEM_ATTACH_START) {
2586 return 0;
2587 }
2588
2589 return GetItemMoney(item_no, sell);
2590}
2591
2599static int WeaponCalMoney(WEAPON_HAVE *weapon, int sell) {
2600 int total;
2601 int i;
2602
2603 if (weapon == NULL) {
2604 return 0;
2605 }
2606
2607 total = 0;
2608
2609 for (i = 0; i < 6; i++) {
2610 ATTACH_LIST *attach = &weapon->attach[i];
2611
2612 if (attach != NULL && attach->item_no >= ITEM_ATTACH_START) {
2613 total += CalItemMoney(attach->item_no, sell);
2614 }
2615 }
2616
2617 return total;
2618}
2619
2627static int BuyMoneyCheck2() {
2628 int total = 0;
2629 int board_max[3] = {100, 60, 40};
2630 int i;
2631 ITEM_PACK *pack = &ShopUserStatusPt->item_pack;
2632
2633 for (i = 0; i < 100; i++) {
2634 if (ItemBoardInfo[i] == SHOP_SLOT_SHOP_GOOD) {
2635 total += CalItemMoney(pack->item[i], 0);
2636 }
2637 }
2638
2639 for (int chara = 0; chara < 6; chara++) {
2640 for (i = 0; i < 10; i++) {
2641 if (WeaponBoardInfo[chara][i] == SHOP_SLOT_SHOP_GOOD) {
2642 WEAPON_HAVE *weapon = &((WEAPON_HAVE *) ((CUserStatus *) ShopUserStatusPt)->chara_weapons[chara])[i];
2643 total += CalItemMoney(weapon->item_no, 0);
2644 total += WeaponCalMoney(weapon, 0);
2645 }
2646 }
2647 }
2648
2649 DNG_CONSUMABLE *attach = ShopUserStatusPt->consumable_items;
2650
2651 for (i = 0; i < 40; i++, attach++) {
2652 if (AttachBoardInfo[i] == SHOP_SLOT_SHOP_GOOD) {
2653 total += CalItemMoney(attach->id, 0);
2654 }
2655 }
2656
2657 return total;
2658}
2659
2667static int SellMoneyCheck2() {
2668 int total = 0;
2669 int i;
2670
2671 for (i = 0; i < 30; i++) {
2672 if (ShopBoardInfo[i] == SHOP_SLOT_PLAYER_ITEM) {
2673 int item_no = ShopListPt[i].item_no;
2674
2675 if (item_no >= ITEM_ATTACH_START) {
2676 int money = CalItemMoney(item_no, 1);
2677
2678 if (item_no >= ITEM_WEAPON_START) {
2679 money += WeaponCalMoney(&ShopListPt[i].data.weapon, 1);
2680 }
2681
2682 total += money;
2683 }
2684 }
2685 }
2686
2687 return total;
2688}
2689
2697static void IncludeBuyItem2() {
2698 int buy = BuyMoneyCheck2();
2699 int balance = SellMoneyCheck2() - buy;
2700 CUserStatus *status;
2701 int money;
2702 int i;
2703 int j;
2704
2705 for (i = 0; i < 30; i++) {
2706 if (ShopBoardInfo[i] == SHOP_SLOT_PLAYER_ITEM) {
2707 ShopBoardInfo[i] = SHOP_SLOT_EMPTY;
2708 memset(&ShopListPt[i], 0, sizeof(SHOP_ITEMLIST));
2709 }
2710 }
2711
2712 for (j = 0; j < 100; j++) {
2713 if (ItemBoardInfo[j] == SHOP_SLOT_SHOP_GOOD) {
2714 ItemBoardInfo[j] = SHOP_SLOT_PLAYER_ITEM;
2715 }
2716 }
2717
2718 // All six characters' weapon rows, walked as one run of sixty slots.
2719 for (i = 0; i < 60; i++) {
2720 if (WeaponBoardInfo[0][i] == SHOP_SLOT_SHOP_GOOD) {
2721 WeaponBoardInfo[0][i] = SHOP_SLOT_PLAYER_ITEM;
2722 }
2723 }
2724
2725 for (i = 0; i < 40; i++) {
2726 if (AttachBoardInfo[i] == SHOP_SLOT_SHOP_GOOD) {
2727 AttachBoardInfo[i] = SHOP_SLOT_PLAYER_ITEM;
2728 }
2729 }
2730
2731 status = ShopUserStatusPt;
2732 money = status->money + balance;
2733
2734 if (money >= 0xFFFF) {
2735 status->money = 0xFFFF;
2736 } else {
2737 status->money = money;
2738 }
2739
2740 ItemShopGoodInitialize(ShopMenu.shop_no);
2741 ItemPosInfoInit();
2742}
2743
2751static int CheckBuyItemFunc2() {
2752 int flags = 1;
2753 int shop_slot;
2754
2755 for (shop_slot = 0; shop_slot < 30; shop_slot++) {
2756 if (ShopBoardInfo[shop_slot] == SHOP_SLOT_PLAYER_ITEM) {
2757 flags |= 2;
2758 break;
2759 }
2760 }
2761
2762 int carried = 0;
2763 ITEM_PACK *pack = ShopUserItemPack(ShopUserStatusPt);
2764 int i;
2765
2766 for (i = 0; i < 3; i++) {
2767 if (pack->quick_item_slot[i] >= ITEM_DUNGEON_START) {
2768 carried += pack->quick_item_qty[i];
2769 }
2770 }
2771
2772 for (i = 0; i < pack->num; i++) {
2773 if (pack->item[i] >= ITEM_DUNGEON_START) {
2774 carried++;
2775 }
2776 }
2777
2778 int board_max[3] = {100, 60, 40};
2779 s32 *board_info[3] = {ItemBoardInfo, WeaponBoardInfo[0], AttachBoardInfo};
2780 int board;
2781 int slot;
2782
2783 for (board = 0; board < 3; board++) {
2784 for (slot = 0; slot < board_max[board]; slot++) {
2785 if (board_info[board][slot] == SHOP_SLOT_SHOP_GOOD) {
2786 flags |= 4;
2787 break;
2788 }
2789 }
2790
2791 if (flags & 4) {
2792 break;
2793 }
2794 }
2795
2796 if ((flags & 4) && carried > pack->num) {
2797 flags = 8;
2798 }
2799
2800 return flags;
2801}
2802
2810static void ExitItemShop2() {
2811 CDngStatusData *dng_status;
2812
2813 ShopCancelGoodReturn2();
2814 ShopMenuExit();
2815
2816 if (SaveData != NULL && ShopMenu.shop_no == 1 && !SaveData->GetGameFlag(0xC8)) {
2817 dng_status = SaveData->GetDngStatus();
2818
2819 if (dng_status != NULL && dng_status->SearchItemIndexNo(5) >= 0) {
2820 SaveData->SetGameFlag(0xC8, 1);
2821 }
2822 }
2823}
2824
2832static void ShopSpecialFunc() {
2833 int found;
2834 int i;
2835 WEAPON_HAVE *weapons;
2836
2837 if (ShopMenu.shop_no == 1) {
2838 found = 0;
2839 weapons = ShopUserStatusPt->chara_weapons[0];
2840
2841 for (i = 0; i < 10; i++) {
2842 if (weapons[i].item_no == 5) {
2843 found = 1;
2844 break;
2845 }
2846 }
2847
2848 if (ShopDataMove.item_no == 5) {
2849 found = 1;
2850 }
2851
2852 if (found) {
2853 for (i = 0; i < 30; i++) {
2854 if (ShopListPt[i].item_no == 5 && ShopBoardInfo[i] == SHOP_SLOT_SHOP_GOOD) {
2855 memset(&ShopListPt[i], 0, sizeof(SHOP_ITEMLIST));
2856 ShopBoardInfo[i] = SHOP_SLOT_EMPTY;
2857 return;
2858 }
2859 }
2860 }
2861 }
2862}
2863
2864s32 sort_table[9] = {9, 0, 1, 2, 3, 4, 5, 6, 7};
2865s32 asort_table[5] = {5, 1, 2, 3, 4};
2866s32 sort_top_type = ITEM_SORT_FOOD;
2867s32 asort_top_type = 1;
2868
2869int CompItem1(int first_item_no, int second_item_no) {
2870 ITEM_DATA *first = GetItemData(first_item_no);
2871 ITEM_DATA *second = GetItemData(second_item_no);
2872 int first_priority = 0;
2873 int second_priority = 0;
2874
2875 if (first != NULL) {
2876 first_priority = sort_table[first->sort_key];
2877 }
2878
2879 if (second != NULL) {
2880 second_priority = sort_table[second->sort_key];
2881 }
2882
2883 if (first_item_no < ITEM_DUNGEON_START) {
2884 first_priority = 9;
2885 }
2886
2887 if (second_item_no < ITEM_DUNGEON_START) {
2888 second_priority = 9;
2889 }
2890
2891 if (second_priority < first_priority) {
2892 return 1;
2893 }
2894
2895 if (first_priority < second_priority) {
2896 return -1;
2897 }
2898
2899 if (second_item_no < first_item_no) {
2900 return 1;
2901 }
2902
2903 if (first_item_no < second_item_no) {
2904 return -1;
2905 }
2906
2907 return 0;
2908}
2909
2910int SeitonShopItemBoardSub(ITEM_PACK *pack) {
2911 int sort_type = sort_top_type;
2912 int first_slot;
2913 int second_slot;
2914 int moved;
2915
2916 for (first_slot = 0; first_slot < ITEM_SORT_COUNT; first_slot++) {
2917 sort_table[sort_type] = first_slot;
2918 sort_type++;
2919
2920 if (sort_type >= ITEM_SORT_COUNT) {
2921 sort_type = ITEM_SORT_NONE;
2922 }
2923 }
2924
2925 sort_table[ITEM_SORT_NONE] = 9;
2926 moved = false;
2927
2928 for (first_slot = 0; first_slot < pack->num - 1; first_slot++) {
2929 for (second_slot = first_slot + 1; second_slot < pack->num; second_slot++) {
2930 if (CompItem1(pack->item[first_slot], pack->item[second_slot]) > 0) {
2931 SwapItem(pack, first_slot, second_slot);
2932 MenuDataSwap(&ItemBoardInfo[first_slot], &ItemBoardInfo[second_slot]);
2933 moved = true;
2934 }
2935 }
2936 }
2937
2938 return moved;
2939}
2940
2948static void SeitonShopItemBoard(ITEM_PACK *pack) {
2949 int i;
2950
2951 if (pack == NULL) {
2952 return;
2953 }
2954
2955 for (i = 0; i < ITEM_SORT_COUNT; i++) {
2956 if (SeitonShopItemBoardSub(pack)) {
2957 return;
2958 }
2959
2960 sort_top_type++;
2961
2962 if (sort_top_type >= ITEM_SORT_COUNT) {
2963 sort_top_type = ITEM_SORT_FOOD;
2964 }
2965 }
2966}
2967
2968int CompAttach1(ATTACH_LIST *first, ATTACH_LIST *second) {
2969 int first_priority = asort_table[GetAttachKind(first->item_no)];
2970 int second_priority = asort_table[GetAttachKind(second->item_no)];
2971 int second_item_no;
2972 int first_item_no;
2973
2974 first_item_no = first->item_no;
2975
2976 if (ITEM_ATTACH_START > first_item_no) {
2977 first_priority = 5;
2978 }
2979
2980 second_item_no = second->item_no;
2981
2982 if (ITEM_ATTACH_START > second_item_no) {
2983 second_priority = 5;
2984 }
2985
2986 if (second_priority < first_priority) {
2987 return 1;
2988 }
2989
2990 if (first_priority < second_priority) {
2991 return -1;
2992 }
2993
2994 if (first_item_no > second_item_no) {
2995 return 1;
2996 }
2997
2998 if (first_item_no < second_item_no) {
2999 return -1;
3000 }
3001
3002 return 0;
3003}
3004
3005int SeitonShopAttachBoardSub(ATTACH_LIST *attachments) {
3006 int sort_type = asort_top_type;
3007 int first_slot;
3008 int second_slot;
3009 int moved;
3010
3011 for (first_slot = 0; first_slot < 5; first_slot++) {
3012 asort_table[sort_type] = first_slot;
3013 sort_type++;
3014
3015 if (sort_type >= 5) {
3016 sort_type = 0;
3017 }
3018 }
3019
3020 asort_table[0] = 5;
3021 moved = false;
3022
3023 for (first_slot = 0; first_slot < 39; first_slot++) {
3024 for (second_slot = first_slot + 1; second_slot < 40; second_slot++) {
3025 if (CompAttach1(&attachments[first_slot], &attachments[second_slot]) > 0) {
3026 MenuDataSwap(&attachments[first_slot], &attachments[second_slot]);
3027 MenuDataSwap(&AttachBoardInfo[first_slot], &AttachBoardInfo[second_slot]);
3028 moved = true;
3029 }
3030 }
3031 }
3032
3033 return moved;
3034}
3035
3043static int SeitonShopAttachBoard(ATTACH_LIST *list) {
3044 int i;
3045
3046 if (list == NULL) {
3047 return 0;
3048 }
3049
3050 for (i = 0; i < 5; i++) {
3051 if (SeitonShopAttachBoardSub(list)) {
3052 break;
3053 }
3054
3055 asort_top_type++;
3056
3057 if (asort_top_type >= 5) {
3058 asort_top_type = 0;
3059 }
3060 }
3061
3062 return 1;
3063}
3064
3065int ItemShopLoop2() {
3066 int done;
3067
3068 ReadBG();
3069 done = ItemShopKey2();
3070 ItemShopDraw2();
3071
3072 if (done) {
3073 ExitItemShop2();
3074 }
3075
3076 return done;
3077}
3078
3079int CheckSideKey2() {
3080 int se;
3081
3082 if (GamePad.Down(PAD_UP | PAD_LEFT) != 0) {
3083 ShopMenu.side = SHOP_SIDE_STOCK;
3084 ShopMenu.board.cursor_area = PERSONAL_BOARD_AREA_CELLS;
3085 ShopMenu.board.cursor = (ShopMenu.stock_top_row + 3) * 5 + 3;
3086 }
3087
3088 if (GamePad.Down(PAD_CROSS) != 0) {
3089 ShopMenu.key_used = 1;
3090
3091 if (ShopHaveItemPt->item_no >= ITEM_ATTACH_START) {
3092 se = 2;
3093 } else {
3094 int flags = CheckBuyItemFunc2();
3095
3096 if (flags & 1) {
3097 se = 2;
3098 SetItemShopTalkMode(SHOP_TALK_NOTHING_MARKED, SHOP_MSG_TALKING);
3099 }
3100
3101 if ((flags & 2) || (flags & 4)) {
3102 int balance;
3103 int buy;
3104 int money = ShopUserStatusPt->money;
3105 buy = BuyMoneyCheck2();
3106 int sell = SellMoneyCheck2();
3107 balance = money + (sell - buy);
3108
3109 if (balance < 0) {
3110 SetItemShopTalkMode(SHOP_TALK_NOT_ENOUGH_MONEY, SHOP_MSG_TALKING);
3111 se = 2;
3112 } else if (balance > 0xFFFF) {
3113 SetItemShopTalkMode(SHOP_TALK_TOO_MUCH_MONEY, SHOP_MSG_TALKING);
3114 se = 2;
3115 } else {
3116 SetItemShopTalkMode(SHOP_TALK_CONFIRM_DEAL, SHOP_MSG_TALKING);
3117 se = 1;
3118 }
3119 }
3120
3121 if (flags & 8) {
3122 SetItemShopTalkMode(SHOP_TALK_INVENTORY_OVERFLOW, SHOP_MSG_TALKING);
3123 }
3124 }
3125
3126 ComMenuSePlay(se);
3127 }
3128
3129 if (GamePad.Down(PAD_RIGHT) != 0) {
3130 ShopMenu.side = SHOP_SIDE_PERSONAL;
3131 ShopMenu.board.cursor = (ShopMenu.board.top_row + 3) * 5;
3132 }
3133
3134 return 0;
3135}
3136
3144static void DrawItemShopBoard2(int x, int y, int alpha) {
3145 int top = y + 9;
3146 int bottom = y + 0xA9;
3147 int board_y;
3148 int left = x + 0x14;
3149
3150 board_y = y + 6 - ShopMenu.stock_top_row * 0x28;
3151 ShopMenu.stock_y += ((float) board_y - ShopMenu.stock_y) / 4.0f;
3152 board_y = ShopMenu.stock_y;
3153 DrawPerBoardDraw(0, 0x1E, left, board_y, top, bottom, ShopBoard, 0x80);
3154
3155 int icon_x = left + 2;
3156 int icon_y = board_y + 6;
3157
3158 for (int i = 0; i < 0x1E; i++) {
3159 int item = ShopListPt[i].item_no;
3160 int num = 0;
3161
3162 if (item >= ITEM_ATTACH_STAT_START && item < ITEM_ATTACH_GEM_START) {
3163 num = ShopListPt[i].data.param[item - ITEM_ATTACH_STAT_START + 4];
3164 }
3165
3166 if (item == ITEM_ATTACH_SYNTHESIS_SPHERE) {
3167 num = ShopListPt[i].data.param[1];
3168 }
3169
3170 DrawIconParts(item, icon_x, icon_y, top, bottom, alpha, num);
3171 icon_x += 0x28;
3172
3173 if (i % 5 == 4) {
3174 icon_x = left + 2;
3175 icon_y += 0x28;
3176 }
3177 }
3178
3179 DrawSellTicket_2(left + 2, board_y + 6, top, bottom, 0x80);
3180
3181 CRect_i_ screen(x, y - 0x13, 0x80, 0x14);
3182 CRect_i_ texel(0x100, 0x7C, 0x80, 0x14);
3183 DrawMenu2DSprite(ShopBoard, screen, texel, alpha);
3184 screen.x += 0x80;
3185 texel.x += 0x80;
3186 texel.y = 0x1C;
3187 DrawMenu2DSprite(ShopBoard, screen, texel, alpha);
3188
3189 PersonalBoardDrawWaku(x, y, ShopBoard, 0x80);
3190 PersonalBoardScrlBarDraw(0x1E, x, y, ShopMenu.stock_scroll, ShopMenu.stock_top_row, ShopBoard, 0x80);
3191 DrawCheckButton(x + 0xA8, y + 0xAA, 0x80);
3192}
3193
3201static void DrawMoneyCheckBoard2(int x, int y, int alpha) {
3202 DrawMenu2DSprite(ShopBoard, CRect_i_(x, y + 1, 0x60, 0x1B), CRect_i_(0xD0, 0xC0, 0x60, 0x1C), alpha);
3203 int buy = BuyMoneyCheck2();
3204 int balance = SellMoneyCheck2() - buy;
3205 RECT digits = {0, 0xDC, 0xC, 0xC};
3206 int u;
3207 int v;
3208
3209 if (balance < 0) {
3210 digits.y += 0xC;
3211 u = 0x84;
3212 v = 0xE8;
3213 }
3214
3215 if (balance > 0) {
3216 digits.y += 0x18;
3217 u = 0x78;
3218 v = 0xF4;
3219 }
3220
3221 x = (int) (x + 0x54);
3222 y = (int) (y + 7);
3223 x = DrawMenuNumber(abs(balance), x, y, ShopBoard, digits, 1, alpha);
3224
3225 if (balance != 0) {
3226 DrawMenu2DSprite(ShopBoard, CRect_i_(x - 0xC, y, 0xC, 0xC), CRect_i_(u, v, 0xC, 0xC), alpha);
3227 }
3228}
3229
3237static void DrawCheckButton(int x, int y, int alpha) {
3238 int u = 0x130;
3239
3240 switch (ShopMenu.talk_mode) {
3241 case SHOP_TALK_BUTTON_FLASH:
3242 u = 0x190;
3243
3244 if (ShopMenu.step_count > 8) {
3245 ShopMenu.talk_mode = SHOP_TALK_NONE;
3246 }
3247
3248 break;
3249 }
3250
3251 DrawMenu2DSprite(ShopBoard, CRect_i_(x, y, 0x60, 0x20), CRect_i_(u, 0x90, 0x60, 0x20), alpha);
3252}
3253
3261static void DrawSmallSellTicket(int selected, int x, int y, int clip_top, int clip_bottom, int alpha) {
3262 int draw_x = x + 0x16;
3263 int draw_y = y + 0x18;
3264 int v = 0xB0;
3265 int height = 0xC;
3266
3267 if (selected) {
3268 v = 0xBC;
3269 }
3270
3271 if (!(clip_top < draw_y + 0xC && clip_bottom > draw_y)) {
3272 return;
3273 }
3274
3275 MenuTextureClip(draw_y, v, height, clip_top, clip_bottom);
3276 DrawMenu2DSprite(ShopBoard, CRect_i_(draw_x, draw_y, 0x10, height), CRect_i_(0x130, v, 0x10, height), alpha);
3277}
3278
3286static void DrawBigSellTicket(int selected, int money, int x, int y, int alpha) {
3287 int draw_x = x + 0x12;
3288 int draw_y = y + 0x14;
3289 int u = 0x1A0;
3290 RECT clip = {0x140, 0xB0, 8, 0xC};
3291
3292 if (selected) {
3293 u = 0x1CC;
3294 clip.y += 0xC;
3295 }
3296
3297 DrawMenu2DSprite(ShopBoard, CRect_i_(draw_x, draw_y, 0x2C, 0x20), CRect_i_(u, 0xB0, 0x2C, 0x20), alpha);
3298 DrawMenuNumber(money, draw_x + 0x24, draw_y + 0xE, ShopBoard, clip, 0, alpha);
3299}
3300
3308static void DrawSellTicket_2(int x, int y, int clip_top, int clip_bottom, int alpha) {
3309 int draw_x = x;
3310 int draw_y = y;
3311 int visible;
3312 int selected;
3313 int state;
3314 int i;
3315
3316 for (i = 0; i < 30; i++) {
3317 state = ShopBoardInfo[i];
3318
3319 if (state == SHOP_SLOT_EMPTY) {
3320 draw_x += 0x28;
3321
3322 if (i % 5 == 4) {
3323 draw_x = x;
3324 draw_y += 0x28;
3325 }
3326 } else {
3327 visible = true;
3328
3329 if (ShopListPt[i].item_no < ITEM_ATTACH_START) {
3330 visible = false;
3331 }
3332
3333 if (ShopMenu.side == SHOP_SIDE_STOCK && i == ShopMenu.board.cursor) {
3334 visible = false;
3335 }
3336
3337 selected = 0;
3338
3339 if (state == SHOP_SLOT_PLAYER_ITEM) {
3340 selected = 1;
3341 }
3342
3343 if (visible) {
3344 DrawSmallSellTicket(selected, draw_x, draw_y, clip_top, clip_bottom, alpha);
3345 }
3346
3347 draw_x += 0x28;
3348
3349 if (i % 5 == 4) {
3350 draw_x = x;
3351 draw_y += 0x28;
3352 }
3353 }
3354 }
3355}
3356
3364static void DrawLocalTicket(int x, int y, int clip_top, int clip_bottom, int slot, int item_no, int alpha) {
3365 int money;
3366 int ticket_x;
3367 int ticket_y;
3368
3369 if (slot == ShopMenu.board.cursor && ShopMenu.side == SHOP_SIDE_PERSONAL) {
3370 money = CalItemMoney(item_no, 0);
3371
3372 if (money < 0) {
3373 money = 1;
3374 }
3375
3376 ticket_x = x + (slot % 5) * 0x28;
3377 ticket_y = y + (slot / 5) * 0x28;
3378
3379 if (ticket_y >= clip_top || ticket_y < clip_bottom) {
3380 DrawBigSellTicket(0, money, ticket_x, ticket_y, 0x80);
3381 }
3382 } else {
3383 ticket_x = x + (slot % 5) * 0x28;
3384 ticket_y = y + (slot / 5) * 0x28;
3385 DrawSmallSellTicket(0, ticket_x, ticket_y, clip_top, clip_bottom, alpha);
3386 }
3387}
3388
3389void DrawSellTicket22(int x, int y, int clip_top, int clip_bottom, int alpha) {
3390 int page = ShopMenu.board.page;
3391 int board_max[3] = {100, 60, 40};
3392 int i;
3393 int j;
3394 int item_no;
3395 ITEM_PACK *pack = &ShopUserStatusPt->item_pack;
3396 DNG_CONSUMABLE *attach = ShopUserStatusPt->consumable_items;
3397 WEAPON_HAVE *weapons;
3398
3399 switch (page) {
3400 case BOARD_PAGE_ITEM:
3401 for (i = 0; i < 100; i++) {
3402 if (ItemBoardInfo[i] == SHOP_SLOT_SHOP_GOOD) {
3403 item_no = pack->item[i];
3404
3405 if (item_no >= ITEM_DUNGEON_START) {
3406 DrawLocalTicket(x, y, clip_top, clip_bottom, i, item_no, alpha);
3407 }
3408 }
3409 }
3410
3411 break;
3412 case BOARD_PAGE_WEAPON:
3413 for (i = 0; i < 6; i++) {
3414 weapons = (WEAPON_HAVE *) ((char *) ShopUserStatusPt + i * sizeof(ShopUserStatusPt->chara_weapons[0]) + 0x450C);
3415
3416 for (j = 0; j < 10; j++) {
3417 if (WeaponBoardInfo[i][j] == SHOP_SLOT_SHOP_GOOD) {
3418 item_no = weapons[j].item_no;
3419
3420 if (item_no >= ITEM_WEAPON_START) {
3421 DrawLocalTicket(x, y, clip_top, clip_bottom, j + i * 10, item_no, 0x80);
3422 }
3423 }
3424 }
3425 }
3426
3427 break;
3428 case BOARD_PAGE_ATTACH:
3429 for (i = 0; i < 40; i++) {
3430 if (AttachBoardInfo[i] == SHOP_SLOT_SHOP_GOOD) {
3431 item_no = attach[i].id;
3432
3433 if (item_no >= ITEM_ATTACH_START) {
3434 DrawLocalTicket(x, y, clip_top, clip_bottom, i, item_no, 0x80);
3435 }
3436 }
3437 }
3438
3439 break;
3440 }
3441}
3442
3450static void ShopCancelGoodReturn2() {
3451 int count = -1;
3452 int page = BOARD_PAGE_NONE;
3453 s32 *info;
3454 ATTACH_LIST *attach = (ATTACH_LIST *) ShopUserStatusPt->consumable_items;
3455 ITEM_PACK *pack = ShopUserItemPack(ShopUserStatusPt);
3456 WEAPON_HAVE *weapon;
3457 int space;
3458 int chara_no;
3459 int slot_no;
3460
3461 // Gather every marked item, weapon and attachment into the work buffer.
3462 for (int i = 0; i < 100; i++) {
3463 if (ItemBoardInfo[i] == SHOP_SLOT_SHOP_GOOD) {
3464 count++;
3465 ShopWorkBuf[count].item_no = pack->item[i];
3466 ShopWorkBuf[count].data.volume = pack->item_vol[i];
3467 pack->item[i] = 0;
3468 pack->item_vol[i] = 0;
3469 ItemBoardInfo[i] = SHOP_SLOT_EMPTY;
3470 }
3471 }
3472
3473 for (int i = 0; i < 60; i++) {
3474 if (WeaponBoardInfo[0][i] == SHOP_SLOT_SHOP_GOOD) {
3475 chara_no = i / 10;
3476 slot_no = i % 10;
3477 CUserStatus *status = ShopUserStatusPt;
3478 WEAPON_HAVE *row = status->chara_weapons[chara_no];
3479 weapon = &row[slot_no];
3480
3481 if (weapon->item_no >= ITEM_WEAPON_START) {
3482 count++;
3483 ShopWorkBuf[count].item_no = weapon->item_no;
3484 memcpy(&ShopWorkBuf[count].data, weapon, sizeof(WEAPON_HAVE));
3485 InitHaveWep(weapon);
3486 WeaponBoardInfo[0][i] = SHOP_SLOT_EMPTY;
3487 }
3488 }
3489 }
3490
3491 for (int i = 0; i < 40; i++) {
3492 if (AttachBoardInfo[i] == SHOP_SLOT_SHOP_GOOD && attach != NULL) {
3493 count++;
3494 ATTACH_LIST *list = &attach[i];
3495 ShopWorkBuf[count].item_no = list->item_no;
3496 memcpy(&ShopWorkBuf[count].data, list, sizeof(ATTACH_LIST));
3497 InitHaveAttach(list);
3498 AttachBoardInfo[i] = SHOP_SLOT_EMPTY;
3499 }
3500 }
3501
3502 // Put the goods on the shop board back on the board they came from.
3503 for (int i = 0; i < 30; i++) {
3504 if (ShopBoardInfo[i] == SHOP_SLOT_PLAYER_ITEM) {
3505 int item_no = ShopListPt[i].item_no;
3506
3507 if (item_no >= ITEM_ATTACH_START) {
3508 space = GetBoardSpace(item_no, &page);
3509
3510 if (space >= 0) {
3511 switch (page) {
3512 case BOARD_PAGE_ITEM:
3513 pack->item[space] = item_no;
3514 pack->item_vol[space] = ShopListPt[i].data.param[0];
3515 info = ItemBoardInfo;
3516 break;
3517 case BOARD_PAGE_WEAPON: {
3518 chara_no = space / 10;
3519 slot_no = space % 10;
3520 WEAPON_HAVE *row = ((CUserStatus *) ShopUserStatusPt)->chara_weapons[chara_no];
3521 weapon = &row[slot_no];
3522 memcpy(weapon, &ShopListPt[i].data, sizeof(WEAPON_HAVE));
3523 weapon->item_no = item_no;
3524 info = WeaponBoardInfo[0];
3525 break;
3526 }
3527 case BOARD_PAGE_ATTACH: {
3528 ATTACH_LIST *list = &attach[space];
3529 memcpy(list, &ShopListPt[i].data, sizeof(ATTACH_LIST));
3530 list->item_no = item_no;
3531 info = AttachBoardInfo;
3532 break;
3533 }
3534 }
3535
3536 info[space] = SHOP_SLOT_PLAYER_ITEM;
3537 memset(&ShopListPt[i], 0, sizeof(SHOP_ITEMLIST));
3538 ShopBoardInfo[i] = SHOP_SLOT_EMPTY;
3539 }
3540 }
3541 }
3542 }
3543
3544 // Refill the emptied shop slots from the work buffer.
3545 int next = 0;
3546
3547 for (int i = 0; i < 30; i++) {
3548 if (ShopListPt[i].item_no < ITEM_ATTACH_START) {
3549 if (next > count) {
3550 break;
3551 }
3552
3553 ShopBoardInfo[i] = SHOP_SLOT_SHOP_GOOD;
3554 memcpy(&ShopListPt[i], &ShopWorkBuf[next], sizeof(SHOP_ITEMLIST));
3555 ShopListPt[i].item_no = ShopWorkBuf[next].item_no;
3556 next++;
3557 }
3558 }
3559}
3560
3568static int GetNowMasterMsgNo2(int shop_kind, int shop_no) {
3569 int mes_no;
3570 int base = shop_kind * 2000;
3571
3572 mes_no = base + 2000 + shop_no * 100;
3573
3574 switch (ShopMenu.talk_mode) {
3575 case SHOP_TALK_GREETING:
3576 break;
3577 case SHOP_TALK_CANNOT_CHARGE:
3578 mes_no += 0x32;
3579 break;
3580 case SHOP_TALK_NOT_ENOUGH_MONEY:
3581 mes_no += 0x34;
3582 break;
3583 case SHOP_TALK_TOO_MUCH_MONEY:
3584 mes_no += 0x38;
3585 break;
3586 case SHOP_TALK_NOTHING_MARKED:
3587 mes_no += 0x33;
3588 break;
3589 case SHOP_TALK_CANNOT_SELL:
3590 mes_no += 0x36;
3591 break;
3592 case SHOP_TALK_WEAPON_EQUIPPED:
3593 mes_no += 0x35;
3594 break;
3595 case SHOP_TALK_STOCK_FULL:
3596 mes_no += 0x3A;
3597 break;
3598 case SHOP_TALK_NO_SPACE:
3599 case SHOP_TALK_INVENTORY_OVERFLOW:
3600 mes_no += 0x37;
3601 break;
3602 case SHOP_TALK_DEAL_PENDING:
3603 mes_no += 0x41;
3604 break;
3605 case SHOP_TALK_CONFIRM_DEAL: {
3606 int flags = CheckBuyItemFunc2();
3607
3608 if (flags & 2) {
3609 mes_no = base + 2070 + shop_no * 100;
3610 }
3611
3612 if (flags & 4) {
3613 mes_no = base + 2071 + shop_no * 100;
3614 }
3615
3616 if (flags & 6) {
3617 mes_no = base + 2072 + shop_no * 100;
3618 }
3619
3620 break;
3621 }
3622 case SHOP_TALK_DEAL_DONE:
3623 mes_no += 0x4B;
3624 break;
3625 case SHOP_TALK_LEAVE_PROMPT:
3626 mes_no += 0x5A;
3627 break;
3628 case SHOP_TALK_GOODBYE:
3629 case SHOP_TALK_FADE_OUT:
3630 mes_no += 0x5B;
3631 break;
3632 case SHOP_TALK_NONE:
3633 switch (ShopMenu.side) {
3634 case SHOP_SIDE_STOCK:
3635 mes_no += 0x14;
3636 break;
3637 case SHOP_SIDE_PERSONAL:
3638 if (ShopMenu.board.cursor_area == PERSONAL_BOARD_AREA_TRASH) {
3639 mes_no += 0x28;
3640 } else {
3641 mes_no += 0x1E;
3642 }
3643
3644 break;
3645 case SHOP_SIDE_CHECK_BUTTON:
3646 mes_no += 0x3C;
3647 break;
3648 }
3649
3650 break;
3651 }
3652
3653 return mes_no;
3654}
3655
3663static void ShopModelMsgFunc(int shop_kind) {
3664 if (ShopMenu.person_state == 2) {
3665 int motion = ShopMenu.motion;
3666
3667 switch (ShopMenu.msg_mode) {
3668 case SHOP_MSG_IDLE:
3669 motion = 0;
3670
3671 if (GamePad.AllOn()) {
3672 ShopMenu.idle_count = 0;
3673 } else {
3674 ShopMenu.idle_count++;
3675
3676 if (ShopMenu.idle_count >= 0x140) {
3677 ShopMenu.msg_mode = SHOP_MSG_TALKING;
3678 motion = 3;
3679 }
3680 }
3681
3682 break;
3683 case SHOP_MSG_TALKING:
3684 switch (ShopMenu.talk_mode) {
3685 case SHOP_TALK_NONE:
3686 if (GamePad.AllOn()) {
3687 ShopMenu.msg_mode = SHOP_MSG_IDLE;
3688 ShopMenu.idle_count = 0;
3689 motion = 0;
3690 }
3691
3692 break;
3693 default:
3694 motion = 3;
3695 break;
3696 }
3697
3698 break;
3699 }
3700
3701 if (ShopMenu.msg_mode == SHOP_MSG_TALKING) {
3702 int msg_no = GetNowMasterMsgNo2(shop_kind, ShopMenu.shop_no);
3703
3704 if (ShopMenu.msg_no != msg_no || GamePad.Down(PAD_CIRCLE | PAD_CROSS)) {
3705 ShopMenu.msg_no = msg_no;
3706 CommonMenuMes3.mes_made = -1;
3707 CommonMenuMes3.MakeMesWin(ShopMenu.msg_no);
3708 motion = 3;
3709 }
3710
3711 switch (ShopMenu.talk_mode) {
3712 case SHOP_TALK_FADE_OUT:
3713 case SHOP_TALK_FADE_IN:
3714 break;
3715 default:
3716 if (ShopMenu.person_state) {
3717 SetShopTalkMsgPos();
3718 CommonMenuMes3.tail_on = true;
3719 CommonMenuMes3.auto_pos = MES_POS_BOTTOM;
3720 CommonMenuMes3.Step();
3721
3722 if (ShopMenu.draw_delay >= 4) {
3723 CommonMenuMes3.DrawMesWin();
3724 }
3725
3726 setbilinear(0);
3727 }
3728
3729 break;
3730 }
3731 }
3732
3733 switch (CommonMenuMes3.State()) {
3734 case CLSMES_CLOSED:
3735 case CLSMES_FADE_OUT:
3736 motion = 0;
3737 break;
3738 case CLSMES_FADE_IN:
3739 case CLSMES_REVEALING:
3740 motion = 3;
3741 break;
3742 }
3743
3744 if (ShopMenu.motion != motion) {
3745 ShopMenu.motion = motion;
3746 MenuCharaFrame.SetMotion(ShopMenu.motion, 0);
3747 }
3748 }
3749}
3750
3759static void SetShopTalkMsgPos() {
3760 float pos[4];
3761 int screen[6];
3762 int msg_pos[2];
3763 float scale[3];
3764
3765 sceVu0CopyVector(pos, MenuCharaFrame.pos);
3766 MenuCharaFrame.GetScale(scale);
3767 pos[0] -= 2.0f;
3768 pos[1] += 0.85f * MenuCharaFrame.body_height;
3769 pos[3] = 1.0f;
3770 MGRotTransPers2D(screen, pos, 0);
3771 msg_pos[0] = screen[0];
3772 msg_pos[1] = screen[1];
3773 CommonMenuMes3.AutoSet(msg_pos);
3774}
3775
3776void ItemShopGetPacFileName(int shop_kind, int shop_no, char *file_name) {
3777 char *names[2][18] = {
3778 {"p13", "p31", "p39", "p54", "p74", "c03", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL },
3779 {"p02", "p32", "p35", "p36", "p36", "p36", "p36", "p37", "p49", "p55", "p75", "c03", "p41", "p02", "p32", "p38",
3780 "c03", "c03"}
3781 };
3782 char file[32];
3783
3784 strcpy(file, names[shop_kind][shop_no]);
3785 strcat(file, "a.pac");
3786 {
3787 char path[64] = "commenu/shopchara/";
3788
3789 strcat(path, file);
3790 strcpy(file_name, path);
3791 }
3792}
3793
3794void ItemShopGetImgFileName(int shop_kind, int shop_no, char *file_name) {
3795 char *names[2][18] = {
3796 {"p13a", "p31a", "p39a", "p54a", "p74a", "c03c", "", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
3797 NULL },
3798 {"p02a", "p32a", "p35a", "p36a", "p36a", "p36a", "p36a", "p37a", "p49a", "p55a", "p75a", "c03c", "p41a", "p02a",
3799 "p32a", "p38a", "c03c", "c03c"}
3800 };
3801
3802 strcpy(file_name, names[shop_kind][shop_no]);
3803 strcat(file_name, "01.img");
3804}
3805
3806void ItemShopMemoryAlloc() {
3807 ShopBoardInfo = (s32 *) ShopCashBuffer.Alloc(0x78);
3808 ItemBoardInfo = (s32 *) ShopCashBuffer.Alloc(0x190);
3809 WeaponBoardInfo = (s32(*)[10]) ShopCashBuffer.Alloc(0xF0);
3810 AttachBoardInfo = (s32 *) ShopCashBuffer.Alloc(0xA0);
3811 memset(ShopBoardInfo, 0, 0x78);
3812 memset(ItemBoardInfo, 0, 0x190);
3813 memset(WeaponBoardInfo, 0, 0xF0);
3814 memset(AttachBoardInfo, 0, 0xA0);
3815 ShopListPt = (SHOP_ITEMLIST *) ShopCashBuffer.Alloc(0x1D88);
3816 memset(ShopListPt, 0, 0x1D88);
3817 ShopWorkBuf = (SHOP_ITEMLIST *) ShopCashBuffer.Alloc(0x1D88);
3818}
3819
3820void ItemPosInfoInit() {
3821 int i;
3822 int j;
3823 ITEM_PACK *pack = ShopUserItemPack(ShopUserStatusPt);
3824
3825 for (i = 0; i < 100; i++) {
3826 if (pack->item[i] >= ITEM_DUNGEON_START) {
3827 ItemBoardInfo[i] = SHOP_SLOT_PLAYER_ITEM;
3828
3829#ifdef PAL
3830 if (DebugMode) {
3831 printf("%d, item exist is %d\n", i, pack->item[i]);
3832 }
3833#endif
3834 } else {
3835 ItemBoardInfo[i] = SHOP_SLOT_EMPTY;
3836 }
3837 }
3838
3839 for (i = 0; i < 6; i++) {
3840 CUserStatus *status = ShopUserStatusPt;
3841 WEAPON_HAVE *weapons = status->chara_weapons[i];
3842
3843 for (j = 0; j < 10; j++) {
3844#ifdef PAL
3845 s16 item_no = weapons[j].item_no;
3846
3847 if (item_no >= ITEM_WEAPON_START) {
3848#else
3849 if (weapons[j].item_no >= ITEM_WEAPON_START) {
3850#endif
3851 WeaponBoardInfo[i][j] = SHOP_SLOT_PLAYER_ITEM;
3852
3853#ifdef PAL
3854 if (DebugMode) {
3855 printf("%d, wep exist is %d\n", i * 10 + j, item_no);
3856 }
3857#endif
3858 } else {
3859 WeaponBoardInfo[i][j] = SHOP_SLOT_EMPTY;
3860 }
3861 }
3862 }
3863
3864 DNG_CONSUMABLE *attach = ShopUserStatusPt->consumable_items;
3865
3866 for (i = 0; i < 40; i++) {
3867 if (attach[i].id >= ITEM_ATTACH_START) {
3868 AttachBoardInfo[i] = SHOP_SLOT_PLAYER_ITEM;
3869
3870#ifdef PAL
3871 if (DebugMode) {
3872 printf("%d, attach exist is %d\n", i, attach[i].id);
3873 }
3874#endif
3875 } else {
3876 AttachBoardInfo[i] = SHOP_SLOT_EMPTY;
3877 }
3878 }
3879}
3880
3889static void ItemShopGoodInitialize(int shop_no) {
3890 s16 *list = GetItemShopList(shop_no);
3891
3892 for (int i = 0; i < 20; i++) {
3893 s16 item_no = list[i];
3894
3895 if (item_no >= ITEM_ATTACH_START) {
3896 switch (WhatIsKindofItem(item_no)) {
3897 case BOARD_PAGE_WEAPON:
3898 WepDataListToHaveCopy(item_no, &ShopListPt[i].data.weapon);
3899 break;
3900 case BOARD_PAGE_ATTACH:
3901 AttachDataListToHaveCopy(item_no, &ShopListPt[i].data.attach);
3902
3903 if (item_no >= ITEM_ATTACH_STAT_START && item_no < ITEM_ATTACH_GEM_START) {
3904 ShopListPt[i].data.param[item_no - ITEM_ATTACH_STAT_START + 4] = 1;
3905 }
3906
3907 break;
3908 case BOARD_PAGE_ITEM:
3909 ShopListPt[i].data.volume = ItemDataToHaveCopy(item_no);
3910 break;
3911 default:
3912 memset(&ShopListPt[i], 0, sizeof(SHOP_ITEMLIST));
3913 break;
3914 }
3915
3916 ShopListPt[i].item_no = item_no;
3917 ShopBoardInfo[i] = SHOP_SLOT_SHOP_GOOD;
3918 } else {
3919 memset(&ShopListPt[i], 0, sizeof(SHOP_ITEMLIST));
3920 ShopBoardInfo[i] = SHOP_SLOT_EMPTY;
3921 }
3922 }
3923
3924 for (int i = 20; i < 30; i++) {
3925 ShopBoardInfo[i] = SHOP_SLOT_EMPTY;
3926 memset(&ShopListPt[i], 0, sizeof(SHOP_ITEMLIST));
3927 }
3928
3929 ShopSpecialFunc();
3930 InitAllHaveData();
3931}
3932
3933void InitItemShop2(int *tex_block, int shop_no, int mode) {
3934 ShopMenuInit(tex_block, shop_no, mode);
3935 ItemShopMemoryAlloc();
3936 ItemShopGoodInitialize(shop_no);
3937 ItemPosInfoInit();
3938 InitAllHaveData();
3939 ShopHaveItemPt->slot_state = SHOP_SLOT_EMPTY;
3940 ShopMenu.board.cursor = 0;
3941 ShopMenu.side = SHOP_SIDE_STOCK;
3942 ShopMenu.stock_top_row = 0;
3943 ShopMenu.stock_scroll = 142.0f + 114.0f * ShopMenu.stock_top_row / 6.0f;
3944 ShopMenu.stock_y = 0x7E - ShopMenu.stock_top_row * 0x28;
3945 ShopMenu.cursor_x = 86.0f;
3946 ShopMenu.cursor_y = 152.0f;
3947 ShopMenu.cursor_x = (ShopMenu.board.cursor % 5) * 0x28 + 0x154;
3948 ShopMenu.cursor_y = 120.0f;
3949 GetMainMenuRightHelpWinLangOffset(ShopHelpWinPos[0], ShopHelpWinPos[1], ShopHelpWinW, ShopHelpWinH);
3950}
3951
3959static void ItemShopSelectKey2() {
3960 int i;
3961 MENU_ITEMDATA swap_data[2];
3962 int swap_item[2];
3963
3964 if (GamePad.Down(PAD_UP) != 0) {
3965 ShopMenu.board.cursor -= 5;
3966
3967 if (ShopMenu.board.cursor < 0) {
3968 ShopMenu.board.cursor += 5;
3969 }
3970
3971 if (ShopMenu.board.cursor / 5 < ShopMenu.stock_top_row) {
3972 ShopMenu.stock_top_row--;
3973 }
3974 }
3975
3976 if (GamePad.Down(PAD_DOWN) != 0) {
3977 if (ShopMenu.board.cursor >= 25) {
3978 ShopMenu.side = SHOP_SIDE_CHECK_BUTTON;
3979 } else {
3980 ShopMenu.board.cursor += 5;
3981 }
3982
3983 if (ShopMenu.stock_top_row + 3 < ShopMenu.board.cursor / 5) {
3984 ShopMenu.stock_top_row++;
3985 }
3986 }
3987
3988 if (GamePad.Down(PAD_LEFT) != 0 && ShopMenu.board.cursor % 5 != 0) {
3989 ShopMenu.board.cursor--;
3990 }
3991
3992 if (GamePad.Down(PAD_RIGHT) != 0) {
3993 if (ShopMenu.board.cursor % 5 == 4) {
3994 ShopMenu.side = SHOP_SIDE_PERSONAL;
3995 ShopMenu.board.cursor = (ShopMenu.board.top_row + (ShopMenu.board.cursor / 5 - ShopMenu.stock_top_row)) * 5;
3996 } else {
3997 ShopMenu.board.cursor++;
3998 }
3999 }
4000
4001 if (ShopMenu.side == SHOP_SIDE_STOCK && ShopMenu.board.cursor > 30) {
4002 while (ShopMenu.board.cursor > 30) {
4003 ShopMenu.board.cursor -= 5;
4004 }
4005
4006 ShopMenu.stock_top_row = ShopMenu.board.cursor / 5 - 2;
4007 ShopMenu.side = SHOP_SIDE_CHECK_BUTTON;
4008 return;
4009 }
4010
4011 if (GamePad.Down(PAD_CROSS) != 0) {
4012 ShopMenu.key_used = 1;
4013 int cursor = ShopMenu.board.cursor;
4014 int shop_info = ShopBoardInfo[cursor];
4015
4016 if (ShopListPt[cursor].item_no < ITEM_ATTACH_START && ShopHaveItemPt->item_no < ITEM_ATTACH_START) {
4017 ComMenuSePlay(MENU_SOUND_REFUSE);
4018 return;
4019 }
4020
4021 int enable = IsEnableCharge(ShopHaveItemPt->item_no);
4022
4023 if (enable != 0) {
4024 int item_no = ShopHaveItemPt->item_no;
4025
4026 if (item_no >= ITEM_DUNGEON_START) {
4027 ITEM_DATA *data = GetItemData(item_no);
4028
4029 if (data != NULL) {
4030 if (data->kind_flags & ITEMKINDF_THROWABLE) {
4031 enable = false;
4032 }
4033
4034 if (ShopHaveItemPt->item_no == ITEM_FISHING_ROD) {
4035 enable = false;
4036 }
4037 }
4038 }
4039
4040 if (ShopHaveItemPt->item_no == ITEM_WEAPON_SERPENT_SWORD && GetMenuHebikiriFlag() == 0) {
4041 enable = false;
4042 }
4043 }
4044
4045 if (ShopMenu.board.held_equipped_slot >= 0) {
4046 ComMenuSePlay(MENU_SOUND_REFUSE);
4047 SetItemShopTalkMode(SHOP_TALK_WEAPON_EQUIPPED, SHOP_MSG_TALKING);
4048 return;
4049 }
4050
4051 if (enable == 0) {
4052 ComMenuSePlay(MENU_SOUND_REFUSE);
4053 SetItemShopTalkMode(SHOP_TALK_CANNOT_SELL, SHOP_MSG_TALKING);
4054 return;
4055 }
4056
4057 shop_info = ShopBoardInfo[cursor];
4058 int have_info = ShopHaveItemPt->slot_state;
4059 memset(swap_data, 0, sizeof(swap_data));
4060 SHOP_ITEMLIST *good = &ShopListPt[cursor];
4061 int held_kind;
4062 int good_kind = WhatIsKindofItem(good->item_no);
4063 swap_item[0] = good->item_no;
4064
4065 switch (good_kind) {
4066 case BOARD_PAGE_ITEM:
4067 swap_data[0].volume = good->data.volume;
4068 break;
4069 case BOARD_PAGE_WEAPON:
4070 memcpy(&swap_data[0], &good->data, sizeof(WEAPON_HAVE));
4071 break;
4072 case BOARD_PAGE_ATTACH:
4073 memcpy(&swap_data[0], &good->data, sizeof(ATTACH_LIST));
4074 break;
4075 default:
4076 InitShopItemListData(good);
4077 break;
4078 }
4079
4080 held_kind = WhatIsKindofItem(ShopHaveItemPt->item_no);
4081 swap_item[1] = ShopHaveItemPt->item_no;
4082
4083 switch (held_kind) {
4084 case BOARD_PAGE_ITEM:
4085 swap_data[1].volume = ShopHaveItemPt->volume;
4086 break;
4087 case BOARD_PAGE_WEAPON:
4088 memcpy(&swap_data[1], ShopHaveWepPt, sizeof(WEAPON_HAVE));
4089 break;
4090 case BOARD_PAGE_ATTACH:
4091 memcpy(&swap_data[1], ShopHaveAttachPt, sizeof(ATTACH_LIST));
4092 break;
4093 }
4094
4095 switch (good_kind) {
4096 case BOARD_PAGE_ITEM:
4097 ShopHaveItemPt->volume = swap_data[0].volume;
4098 break;
4099 case BOARD_PAGE_WEAPON:
4100 memcpy(ShopHaveWepPt, &swap_data[0], sizeof(WEAPON_HAVE));
4101 break;
4102 case BOARD_PAGE_ATTACH:
4103 memcpy(ShopHaveAttachPt, &swap_data[0], sizeof(ATTACH_LIST));
4104 break;
4105 }
4106
4107 ShopHaveItemPt->item_no = swap_item[0];
4108
4109 switch (held_kind) {
4110 case BOARD_PAGE_ITEM:
4111 good->data.volume = swap_data[1].volume;
4112 break;
4113 case BOARD_PAGE_WEAPON:
4114 memcpy(&good->data, &swap_data[1], sizeof(WEAPON_HAVE));
4115 break;
4116 case BOARD_PAGE_ATTACH:
4117 memcpy(&good->data, &swap_data[1], sizeof(ATTACH_LIST));
4118 break;
4119 }
4120
4121 good->item_no = swap_item[1];
4122 ShopHaveItemPt->slot_state = shop_info;
4123 ShopBoardInfo[cursor] = have_info;
4124
4125 if (ShopHaveItemPt->item_no < ITEM_ATTACH_START) {
4126 InitAllHaveData();
4127 ShopMenu.board.held_equipped_slot = -1;
4128 } else {
4129 ShopHaveItemPt->last_slot = cursor;
4130 ShopMenu.board.page = good_kind;
4131 PersonalBoardLimmitCheck();
4132 }
4133
4134 ComMenuSePlay(MENU_SOUND_CONFIRM);
4135 } else if (GamePad.Down(PAD_TRIANGLE) != 0) {
4136 ShopMenu.key_used = 1;
4137
4138 if (ShopHaveItemPt->item_no >= ITEM_ATTACH_START) {
4139 ComMenuSePlay(MENU_SOUND_REFUSE);
4140 return;
4141 }
4142
4143 if (ShopBoardInfo[ShopMenu.board.cursor] == SHOP_SLOT_SHOP_GOOD) {
4144 int money = ShopUserStatusPt->money;
4145 int item_no = ShopListPt[ShopMenu.board.cursor].item_no;
4146 int price = CalItemMoney(item_no, 0);
4147 int enable = true;
4148
4149 if (item_no < ITEM_ATTACH_START) {
4150 enable = false;
4151 }
4152
4153 if (money < price) {
4154 enable = false;
4155 SetItemShopTalkMode(SHOP_TALK_NOT_ENOUGH_MONEY, SHOP_MSG_TALKING);
4156 }
4157
4158 int page = WhatIsKindofItem(item_no);
4159
4160 if (GetBoardSpace(item_no, &page) < 0) {
4161 enable = false;
4162 SetItemShopTalkMode(SHOP_TALK_NO_SPACE, SHOP_MSG_TALKING);
4163 }
4164
4165 int full = 0;
4166 int max = 0;
4167 int used = 0;
4168 int owner = WhoIsWeaponEquip(item_no);
4169
4170 switch (page) {
4171 case BOARD_PAGE_ITEM: {
4172 int j;
4173 ITEM_PACK *pack = &ShopUserStatusPt->item_pack;
4174 max = pack->num;
4175
4176 for (j = 0; j < 3; j++) {
4177 if (pack->quick_item_slot[j] >= ITEM_DUNGEON_START) {
4178 used += pack->quick_item_qty[j];
4179 }
4180 }
4181
4182 for (int k = 0; k < max; k++) {
4183 if (pack->item[k] >= ITEM_DUNGEON_START) {
4184 used++;
4185 }
4186 }
4187
4188 break;
4189 }
4190 case BOARD_PAGE_WEAPON: {
4191 int j;
4192 max = 10;
4193 CUserStatus *status = ShopUserStatusPt;
4194 WEAPON_HAVE *weapons = status->chara_weapons[owner];
4195
4196 for (j = 0; j < 10; j++) {
4197 if (weapons[j].item_no >= ITEM_WEAPON_START) {
4198 used++;
4199 }
4200 }
4201
4202 break;
4203 }
4204 case BOARD_PAGE_ATTACH: {
4205 int j;
4206 max = 40;
4207 DNG_CONSUMABLE *attach = ShopUserStatusPt->consumable_items;
4208
4209 for (j = 0; j < 40; j++) {
4210 if (attach[j].id >= ITEM_ATTACH_START) {
4211 used++;
4212 }
4213 }
4214
4215 break;
4216 }
4217 }
4218
4219 if (ShopDataMove.item_no > 0) {
4220 used++;
4221 }
4222
4223 for (int k = 0; k < 30; k++) {
4224 if (page >= 0 && page == WhatIsKindofItem(ShopListPt[k].item_no) && ShopBoardInfo[k] == SHOP_SLOT_PLAYER_ITEM) {
4225 if (page == BOARD_PAGE_WEAPON) {
4226 if (owner == WhoIsWeaponEquip(ShopListPt[k].item_no)) {
4227 used++;
4228 }
4229 } else {
4230 used++;
4231 }
4232 }
4233 }
4234
4235 if (used >= max) {
4236 full = 1;
4237 }
4238
4239 if (full != 0) {
4240 enable = false;
4241 SetItemShopTalkMode(SHOP_TALK_NO_SPACE, SHOP_MSG_TALKING);
4242 }
4243
4244 if (enable != 0) {
4245 ShopMenu.talk_mode = SHOP_TALK_BUY_PROMPT;
4246 ComMenuSePlay(MENU_SOUND_CONFIRM);
4247 } else {
4248 ComMenuSePlay(MENU_SOUND_REFUSE);
4249 }
4250 } else {
4251 ComMenuSePlay(MENU_SOUND_REFUSE);
4252 }
4253 }
4254
4255 if (BoardModeChangeKey() != 0) {
4256 PersonalBoardLimmitCheck();
4257 ComMenuSePlay(MENU_SOUND_CURSOR);
4258 }
4259
4260#ifdef PAL
4261 // Debug shortcut: dumps the held item.
4262 if (DebugMode && GamePad.Down2(PAD_UP)) {
4263 printf("------nowHaveData---------\n");
4264 printf("flag = %d\n", ShopHaveItemPt->slot_state);
4265 printf("mode = %d\n", ShopHaveItemPt->from_page);
4266 printf("listno = %d\n", ShopHaveItemPt->item_no);
4267 printf("select = %d\n", ShopHaveItemPt->from_slot);
4268 printf("pos = %d\n", ShopHaveItemPt->last_slot);
4269 printf("listno = %d\n", ShopHaveItemPt->item_no);
4270
4271 if (0 <= ShopHaveItemPt->item_no && ShopHaveItemPt->item_no < ITEM_ATTACH_START) {
4272 printf("wepIndex = %d\n", ShopHaveWepPt->item_no);
4273 }
4274 }
4275#endif
4276}
4277
4278static inline void ShopSwapHeldGood(SHOP_ITEMLIST *good) {
4279 MENU_ITEMDATA swap_data[2];
4280
4281 memset(swap_data, 0, sizeof(swap_data));
4282 int held_kind;
4283 int good_kind = WhatIsKindofItem(good->item_no);
4284
4285 switch (good_kind) {
4286 case BOARD_PAGE_ITEM:
4287 swap_data[0].volume = good->data.volume;
4288 break;
4289 case BOARD_PAGE_WEAPON:
4290 memcpy(&swap_data[0], &good->data, sizeof(WEAPON_HAVE));
4291 break;
4292 case BOARD_PAGE_ATTACH:
4293 memcpy(&swap_data[0], &good->data, sizeof(ATTACH_LIST));
4294 break;
4295 }
4296
4297 held_kind = WhatIsKindofItem(ShopHaveItemPt->item_no);
4298
4299 switch (held_kind) {
4300 case BOARD_PAGE_ITEM:
4301 swap_data[1].volume = ShopHaveItemPt->volume;
4302 break;
4303 case BOARD_PAGE_WEAPON:
4304 memcpy(&swap_data[1], ShopHaveWepPt, sizeof(WEAPON_HAVE));
4305 break;
4306 case BOARD_PAGE_ATTACH:
4307 memcpy(&swap_data[1], ShopHaveAttachPt, sizeof(ATTACH_LIST));
4308 break;
4309 }
4310
4311 switch (good_kind) {
4312 case BOARD_PAGE_ITEM:
4313 ShopHaveItemPt->volume = swap_data[0].volume;
4314 break;
4315 case BOARD_PAGE_WEAPON:
4316 memcpy(ShopHaveWepPt, &swap_data[0], sizeof(WEAPON_HAVE));
4317 break;
4318 case BOARD_PAGE_ATTACH:
4319 memcpy(ShopHaveAttachPt, &swap_data[0], sizeof(ATTACH_LIST));
4320 break;
4321 }
4322
4323 switch (held_kind) {
4324 case BOARD_PAGE_ITEM:
4325 good->data.volume = swap_data[1].volume;
4326 break;
4327 case BOARD_PAGE_WEAPON:
4328 memcpy(&good->data, &swap_data[1], sizeof(WEAPON_HAVE));
4329 break;
4330 case BOARD_PAGE_ATTACH:
4331 memcpy(&good->data, &swap_data[1], sizeof(ATTACH_LIST));
4332 break;
4333 }
4334}
4335
4336static inline int ShopHeldInfo() {
4337 return ShopHaveItemPt->slot_state;
4338}
4339
4340int ItemShopKey2() {
4341#ifdef PAL
4342 // Declared ahead of result so the personal-board cancel path keeps retail's callee-saved registers.
4343 int held_info;
4344 s32 *slot;
4345#endif
4346 int result = 0;
4347 MENU_ITEMDATA record;
4348
4349 if (ShopMenu.ready == 0) {
4350 if (ReadBGSync() == 0) {
4351 ShopTextureLoadFix();
4352 ShopPersonReadStart(SHOP_KIND_ITEM, ShopMenu.shop_no);
4353 }
4354 } else {
4355 switch (ShopMenu.talk_mode) {
4356 case SHOP_TALK_FADE_IN:
4357 ShopMenu.alpha += 8;
4358
4359 if (ShopMenu.alpha >= 0x80) {
4360 ShopMenu.alpha = 0x80;
4361 }
4362
4363 if (ShopMenu.step_count > 20 && ShopMenu.ready != 0 && ShopMenu.alpha >= 0x80) {
4364 ShopMenu.talk_mode = SHOP_TALK_NONE;
4365 }
4366
4367 break;
4368 case SHOP_TALK_FADE_OUT:
4369 ShopMenu.alpha -= 8;
4370
4371 if (ShopMenu.alpha <= 0) {
4372 ShopMenu.alpha = 0;
4373 }
4374
4375 if (ShopMenu.step_count > 26 && ShopMenu.alpha <= 0) {
4376 result = 1;
4377 }
4378
4379 break;
4380 case SHOP_TALK_SELL_PROMPT:
4381 if (GamePad.Down(PAD_TRIANGLE | PAD_CROSS) != 0) {
4382 s16 cursor = ShopMenu.board.cursor;
4383 int item_no;
4384 int money;
4385 s32 *info;
4386 WEAPON_HAVE *weapon;
4387
4388 switch (ShopMenu.board.page) {
4389 case BOARD_PAGE_ITEM: {
4390 ITEM_PACK *pack = &ShopUserStatusPt->item_pack;
4391 item_no = pack->item[cursor];
4392 pack->item[cursor] = -1;
4393 pack->item_vol[cursor] = 0;
4394 info = ItemBoardInfo;
4395 break;
4396 }
4397 case BOARD_PAGE_ATTACH: {
4398 ATTACH_LIST *list = &((ATTACH_LIST *) ShopUserStatusPt->consumable_items)[cursor];
4399 item_no = list->item_no;
4400 memset(list, 0, sizeof(ATTACH_LIST));
4401 info = AttachBoardInfo;
4402 break;
4403 }
4404 case BOARD_PAGE_WEAPON: {
4405 CUserStatus *status = ShopUserStatusPt;
4406 WEAPON_HAVE *row;
4407 weapon = &(row = status->chara_weapons[cursor / 10])[cursor % 10];
4408 item_no = weapon->item_no;
4409 info = WeaponBoardInfo[0];
4410 break;
4411 }
4412 }
4413
4414 money = CalItemMoney(item_no, 1);
4415
4416 if (item_no >= ITEM_WEAPON_START) {
4417 money += WeaponCalMoney(weapon, 1);
4418 memset(weapon, 0, sizeof(WEAPON_HAVE));
4419 }
4420
4421 CUserStatus *status = ShopUserStatusPt;
4422 int total = status->money + money;
4423
4424 if (total >= 0xFFFF) {
4425 status->money = 0xFFFF;
4426 } else {
4427 status->money = total;
4428 }
4429
4430 info[cursor] = SHOP_SLOT_EMPTY;
4431 ShopMenu.talk_mode = SHOP_TALK_NONE;
4432 ComMenuSePlay(SE_PURCHASE);
4433 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
4434 ShopMenu.talk_mode = SHOP_TALK_NONE;
4435 ComMenuSePlay(MENU_SOUND_REFUSE);
4436 }
4437
4438 break;
4439 case SHOP_TALK_BUY_PROMPT:
4440 if (CommonMenuMes1.mes_made != 0x4B4) {
4441 CommonMenuMes1.MakeMesWin(0x4B4);
4442 }
4443
4444 if (GamePad.Down(PAD_TRIANGLE | PAD_CROSS) != 0) {
4445 int item_no = ShopListPt[ShopMenu.board.cursor].item_no;
4446 ShopDataMoveFinish();
4447 int price = CalItemMoney(item_no, 0);
4448 int page = WhatIsKindofItem(item_no);
4449 int space = GetBoardSpace(item_no, &page);
4450 s32 *info;
4451 int icon = space - ShopMenu.board.top_row * 5;
4452
4453 switch (page) {
4454 case BOARD_PAGE_ITEM:
4455 record.volume = ShopListPt[ShopMenu.board.cursor].data.volume;
4456 info = ItemBoardInfo;
4457 break;
4458 case BOARD_PAGE_WEAPON:
4459 memcpy(&record, &ShopListPt[ShopMenu.board.cursor].data, sizeof(WEAPON_HAVE));
4460 info = WeaponBoardInfo[0];
4461 break;
4462 case BOARD_PAGE_ATTACH:
4463 memcpy(&record, &ShopListPt[ShopMenu.board.cursor].data, sizeof(ATTACH_LIST));
4464 info = AttachBoardInfo;
4465 break;
4466 }
4467
4468 ShopMenu.board.page = page;
4469 int row = ShopMenu.board.cursor / 5 - ShopMenu.stock_top_row;
4470 int x = ShopMenu.board.cursor % 5 * 0x28 + 0x34;
4471 int y = row * 0x28 + 0x94;
4472 ShopDataMove.IconMoveTarSet(space, icon, item_no, &record, x, y, 0);
4473
4474 if (icon < 0 || icon >= 20) {
4475 ShopDataMove.IconAutoMove(ChargeOrShopFlag, 1);
4476 ShopDataMoveClear();
4477 }
4478
4479 info[space] = SHOP_SLOT_PLAYER_ITEM;
4480 PersonalBoardLimmitCheck();
4481 ShopSpecialFunc();
4482 CUserStatus *status = ShopUserStatusPt;
4483 int money = status->money;
4484
4485 if (money - price >= 0xFFFF) {
4486 status->money = 0xFFFF;
4487 } else {
4488 status->money += -price;
4489 }
4490
4491 SetItemShopTalkMode(SHOP_TALK_NONE, SHOP_MSG_IDLE);
4492 ComMenuSePlay(SE_PURCHASE);
4493 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
4494 SetItemShopTalkMode(SHOP_TALK_NONE, SHOP_MSG_IDLE);
4495 ComMenuSePlay(MENU_SOUND_REFUSE);
4496 }
4497
4498 break;
4499 case SHOP_TALK_DEAL_PENDING:
4500 case SHOP_TALK_INVENTORY_OVERFLOW:
4501 CommonMenuMes3.page_arrow = true;
4502
4503 if (GamePad.Down(PAD_CROSS) != 0) {
4504 SetItemShopTalkMode(SHOP_TALK_NONE, SHOP_MSG_IDLE);
4505 ComMenuSePlay(MENU_SOUND_CONFIRM);
4506 CommonMenuMes3.page_arrow = false;
4507 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
4508 ComMenuSePlay(MENU_SOUND_REFUSE);
4509 CommonMenuMes3.page_arrow = false;
4510 SetItemShopTalkMode(SHOP_TALK_NONE, SHOP_MSG_IDLE);
4511 ShopCancelGoodReturn2();
4512 }
4513
4514 break;
4515 case SHOP_TALK_CANNOT_SELL:
4516 case SHOP_TALK_WEAPON_EQUIPPED:
4517 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
4518 ShopMenu.talk_mode = SHOP_TALK_NONE;
4519 int item_no = ShopHaveItemPt->item_no;
4520 int page;
4521 int space = GetBoardSpace(item_no, &page);
4522
4523 if (space < 0) {
4524 ComMenuSePlay(MENU_SOUND_REFUSE);
4525 } else {
4526 CUserStatus *status = ShopUserStatusPt;
4527 ITEM_PACK *pack = &status->item_pack;
4528 ATTACH_LIST *attach = (ATTACH_LIST *) status->consumable_items;
4529
4530 switch (page) {
4531 case BOARD_PAGE_ITEM:
4532 pack->item[space] = item_no;
4533 pack->item_vol[space] = ShopHaveItemPt->volume;
4534 break;
4535 case BOARD_PAGE_WEAPON: {
4536 int chara = space / 10;
4537 int slot = space % 10;
4538 WEAPON_HAVE *row = status->chara_weapons[chara];
4539 WEAPON_HAVE *weapon = &row[slot];
4540 memcpy(weapon, ShopHaveWepPt, sizeof(WEAPON_HAVE));
4541 weapon->item_no = item_no;
4542
4543 if (ShopMenu.board.held_equipped_slot >= 0) {
4544 ShopUserStatusPt->equipped_weapon_slot[chara] = slot;
4545 ShopMenu.board.held_equipped_slot = -1;
4546 }
4547
4548 break;
4549 }
4550 case BOARD_PAGE_ATTACH: {
4551 ATTACH_LIST *list = &attach[space];
4552 memcpy(list, ShopHaveAttachPt, sizeof(ATTACH_LIST));
4553 list->item_no = item_no;
4554 break;
4555 }
4556 }
4557
4558 InitAllHaveData();
4559 ComMenuSePlay(MENU_SOUND_REFUSE);
4560 }
4561 }
4562
4563 break;
4564 case SHOP_TALK_GREETING:
4565 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS | PAD_DPAD) != 0) {
4566 ShopMenu.talk_mode = SHOP_TALK_NONE;
4567 CommonMenuMes3.page_arrow = false;
4568 }
4569
4570 break;
4571 case SHOP_TALK_UNK_9:
4572 case SHOP_TALK_NO_SPACE:
4573 case SHOP_TALK_UNK_10:
4574 case SHOP_TALK_DEAL_DONE:
4575 case SHOP_TALK_NOT_ENOUGH_MONEY:
4576 case SHOP_TALK_TOO_MUCH_MONEY:
4577 case SHOP_TALK_NOTHING_MARKED:
4578 CommonMenuMes3.page_arrow = true;
4579
4580 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
4581 ComMenuSePlay(MENU_SOUND_REFUSE);
4582 SetItemShopTalkMode(SHOP_TALK_NONE, SHOP_MSG_IDLE);
4583 CommonMenuMes3.page_arrow = false;
4584 }
4585
4586 break;
4587 case SHOP_TALK_GOODBYE:
4588 CommonMenuMes3.page_arrow = true;
4589
4590 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
4591 ShopMenu.talk_mode = SHOP_TALK_FADE_OUT;
4592 ShopMenu.step_count = 0;
4593 CommonMenuMes3.page_arrow = false;
4594 ComMenuSePlay(MENU_SOUND_REFUSE);
4595 }
4596
4597 break;
4598 case SHOP_TALK_LEAVE_PROMPT:
4599 CommonMenuMes3.page_arrow = true;
4600
4601 if (GamePad.Down(PAD_CROSS) != 0) {
4602 SetItemShopTalkMode(SHOP_TALK_NONE, SHOP_MSG_IDLE);
4603 CommonMenuMes3.page_arrow = false;
4604 ComMenuSePlay(MENU_SOUND_CONFIRM);
4605 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
4606 SetItemShopTalkMode(SHOP_TALK_GOODBYE, SHOP_MSG_TALKING);
4607 CommonMenuMes3.page_arrow = false;
4608 ComMenuSePlay(MENU_SOUND_CONFIRM);
4609 }
4610
4611 break;
4612 case SHOP_TALK_CONFIRM_DEAL:
4613 if (GamePad.Down(PAD_CROSS) != 0) {
4614 SetItemShopTalkMode(SHOP_TALK_DEAL_DONE, SHOP_MSG_TALKING);
4615 IncludeBuyItem2();
4616 ComMenuSePlay(SE_PURCHASE);
4617 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
4618 SetItemShopTalkMode(SHOP_TALK_NONE, SHOP_MSG_IDLE);
4619 ComMenuSePlay(MENU_SOUND_REFUSE);
4620 }
4621
4622 break;
4623 case SHOP_TALK_NONE: {
4624 if (ShopMenu.person_state == 0) {
4625 ShopMenu.person_state = ShopPersonBuild(SHOP_KIND_ITEM, ShopMenu.shop_no);
4626 }
4627
4628 int cursor = ShopMenu.board.cursor;
4629 int old_page = ShopMenu.board.page;
4630
4631 switch (ShopMenu.side) {
4632 case SHOP_SIDE_CHECK_BUTTON:
4633 CheckSideKey2();
4634 break;
4635 case SHOP_SIDE_STOCK:
4636 ItemShopSelectKey2();
4637 break;
4638 case SHOP_SIDE_PERSONAL: {
4639 int board_exit = PersonalBoardKey();
4640
4641 if (board_exit == 0 && GamePad.Down(PAD_CROSS) != 0) {
4642 int pos;
4643 int slot_info;
4644 PERSONAL_BOARD *board = &ShopMenu.board;
4645 int held_info = ShopHeldInfo();
4646
4647 switch (board->cursor_area) {
4648 case PERSONAL_BOARD_AREA_TRASH: {
4649 ComMenuSePlay(MENU_SOUND_REFUSE);
4650 s16 held = ShopHaveItemPt->item_no;
4651
4652 if (held >= ITEM_ATTACH_START && held_info != SHOP_SLOT_SHOP_GOOD && IsEnableTrushThrow(held) != 0) {
4653 board->trash_anim = 1;
4654 board->trash_frame = 0;
4655 ShopHaveItemPt->item_no = 0;
4656 }
4657
4658 break;
4659 }
4660 case PERSONAL_BOARD_AREA_CELLS: {
4661 s32 *info;
4662 pos = ShopMenu.board.cursor;
4663
4664 switch (ShopMenu.board.page) {
4665 case BOARD_PAGE_ITEM:
4666 info = ItemBoardInfo;
4667 break;
4668 case BOARD_PAGE_WEAPON:
4669 info = WeaponBoardInfo[0];
4670 break;
4671 case BOARD_PAGE_ATTACH:
4672 info = AttachBoardInfo;
4673 break;
4674 }
4675
4676 slot_info = info[pos];
4677
4678 if (ShopMenu.board.page == BOARD_PAGE_WEAPON && held_info == SHOP_SLOT_SHOP_GOOD && (ShopHaveItemPt->item_no == ITEM_REPAIR_POWDER || ShopHaveItemPt->item_no == ITEM_POWERUP_POWDER)) {
4679 ComMenuSePlay(MENU_SOUND_REFUSE);
4680 } else if (PersonalBoardItemGetorSwap(pos) != 1) {
4681 ComMenuSePlay(MENU_SOUND_REFUSE);
4682 } else {
4683 ShopHaveItemPt->slot_state = slot_info;
4684 info[pos] = held_info;
4685
4686 if (ShopHaveItemPt->item_no < ITEM_ATTACH_START) {
4687 InitAllHaveData();
4688 ShopMenu.board.held_equipped_slot = -1;
4689 } else {
4690 ShopHaveItemPt->last_slot = pos;
4691 }
4692
4693 ComMenuSePlay(MENU_SOUND_CONFIRM);
4694 }
4695
4696 break;
4697 }
4698 }
4699 } else if (board_exit == 0 && GamePad.Down(PAD_TRIANGLE) != 0) {
4700 ShopMenu.key_used = 1;
4701
4702 if (ShopHaveItemPt->item_no >= ITEM_ATTACH_START) {
4703 ComMenuSePlay(MENU_SOUND_REFUSE);
4704 return 0;
4705 }
4706
4707 int target = SearchBoardNowPosItemExist(ShopMenu.board.page, ShopMenu.board.cursor);
4708 s32 *slot;
4709
4710 switch (ShopMenu.board.page) {
4711 case BOARD_PAGE_ITEM:
4712 slot = &ItemBoardInfo[ShopMenu.board.cursor];
4713 break;
4714 case BOARD_PAGE_ATTACH:
4715 slot = &AttachBoardInfo[ShopMenu.board.cursor];
4716 break;
4717 case BOARD_PAGE_WEAPON:
4718 slot = &WeaponBoardInfo[0][ShopMenu.board.cursor];
4719 break;
4720 }
4721
4722 if (*slot == SHOP_SLOT_SHOP_GOOD) {
4723 ComMenuSePlay(MENU_SOUND_REFUSE);
4724 } else {
4725 int enable = IsEnableCharge(target);
4726
4727 if (enable != 0) {
4728 if (target <= ITEM_WEAPON_START && target >= ITEM_DUNGEON_START) {
4729 ITEM_DATA *data = GetItemData(target);
4730
4731 if (data != NULL && ((data->kind_flags & 0x10) || ShopHaveItemPt->item_no == ITEM_FISHING_ROD)) {
4732 enable = false;
4733 SetItemShopTalkMode(SHOP_TALK_CANNOT_SELL, SHOP_MSG_TALKING);
4734 }
4735 }
4736
4737 if (target >= ITEM_WEAPON_START) {
4738 int chara = ShopMenu.board.cursor / 10;
4739
4740 if (chara == IsDefaultWeapon(target)) {
4741 SetItemShopTalkMode(SHOP_TALK_CANNOT_SELL, SHOP_MSG_TALKING);
4742 enable = false;
4743 }
4744
4745 if (target == 0x10C && GetMenuHebikiriFlag() == 0) {
4746 SetItemShopTalkMode(SHOP_TALK_CANNOT_SELL, SHOP_MSG_TALKING);
4747 enable = false;
4748 }
4749
4750 int owner = ShopMenu.board.cursor / 10;
4751 CUserStatus *status = ShopUserStatusPt;
4752 s8 slot = status->equipped_weapon_slot[owner];
4753
4754 if (ShopMenu.board.cursor % 10 == slot) {
4755 enable = false;
4756 SetItemShopTalkMode(SHOP_TALK_WEAPON_EQUIPPED, SHOP_MSG_TALKING);
4757 }
4758 }
4759 } else {
4760 SetItemShopTalkMode(SHOP_TALK_CANNOT_SELL, SHOP_MSG_TALKING);
4761 }
4762
4763 int money;
4764 int wallet = ShopUserStatusPt->money;
4765 money = CalItemMoney(target, 1);
4766
4767 if (target >= ITEM_WEAPON_START) {
4768 money += WeaponCalMoney(&ShopWeaponRow(ShopUserStatusPt, ShopMenu.board.cursor / 10)[ShopMenu.board.cursor % 10], 1);
4769 }
4770
4771 if (money <= 0) {
4772 money = 1;
4773 }
4774
4775 if (wallet + money > 0xFFFF) {
4776 SetItemShopTalkMode(SHOP_TALK_TOO_MUCH_MONEY, SHOP_MSG_TALKING);
4777 enable = false;
4778 }
4779
4780 if (target < ITEM_ATTACH_START) {
4781 ComMenuSePlay(MENU_SOUND_REFUSE);
4782 } else if (enable != 0) {
4783 ShopMenu.talk_mode = SHOP_TALK_SELL_PROMPT;
4784 ComMenuSePlay(MENU_SOUND_CONFIRM);
4785 } else {
4786 ComMenuSePlay(MENU_SOUND_REFUSE);
4787 }
4788 }
4789 }
4790
4791 if (board_exit != 0) {
4792 ShopMenu.side = SHOP_SIDE_STOCK;
4793 ShopMenu.board.cursor = (ShopMenu.stock_top_row + (ShopMenu.board.cursor / 5 - ShopMenu.board.top_row)) * 5 + 4;
4794 }
4795
4796 break;
4797 }
4798 }
4799
4800 if (ShopMenu.key_used == 0 && GamePad.Down(PAD_CIRCLE) != 0) {
4801 ComMenuSePlay(MENU_SOUND_REFUSE);
4802 s16 held = ShopHaveItemPt->item_no;
4803
4804 if (held < ITEM_ATTACH_START) {
4805 if (ShopMenu.side == SHOP_SIDE_CHECK_BUTTON) {
4806 CommonMenuMes3.mes_made = -1;
4807 ShopMenu.msg_mode = SHOP_MSG_TALKING;
4808 int flags = CheckBuyItemFunc2();
4809
4810 if (flags & 1) {
4811 ShopMenu.talk_mode = SHOP_TALK_LEAVE_PROMPT;
4812 }
4813
4814 if (flags & 6) {
4815 ShopMenu.talk_mode = SHOP_TALK_DEAL_PENDING;
4816 ShopMenu.side = SHOP_SIDE_CHECK_BUTTON;
4817 }
4818
4819 if (flags & 8) {
4820 ShopMenu.talk_mode = SHOP_TALK_INVENTORY_OVERFLOW;
4821 }
4822 } else {
4823 ShopMenu.side = SHOP_SIDE_CHECK_BUTTON;
4824 }
4825 } else {
4826#ifdef PAL
4827 held_info = ShopHaveItemPt->slot_state;
4828#else
4829 int held_info = ShopHaveItemPt->slot_state;
4830#endif
4831 s32 *info;
4832
4833 switch (held_info) {
4834 case SHOP_SLOT_SHOP_GOOD: {
4835 int free = -1;
4836
4837 for (int i = 0; i < 30; i++) {
4838 if (ShopBoardInfo[i] == SHOP_SLOT_EMPTY) {
4839 free = i;
4840 break;
4841 }
4842 }
4843
4844 if (free < 0) {
4845 ComMenuSePlay(MENU_SOUND_REFUSE);
4846 } else {
4847 SHOP_ITEMLIST *good = &ShopListPt[free];
4848 ShopSwapHeldGood(good);
4849 MenuDataSwap(&ShopHaveItemPt->slot_state, &ShopBoardInfo[free]);
4850 MenuDataSwap(&ShopHaveItemPt->item_no, &good->item_no);
4851 }
4852
4853 break;
4854 }
4855 case SHOP_SLOT_PLAYER_ITEM: {
4856 int page = WhatIsKindofItem(held);
4857
4858 switch (page) {
4859 case BOARD_PAGE_ITEM:
4860 info = ItemBoardInfo;
4861 break;
4862 case BOARD_PAGE_WEAPON:
4863 info = WeaponBoardInfo[0];
4864 break;
4865 case BOARD_PAGE_ATTACH:
4866 info = AttachBoardInfo;
4867 break;
4868 }
4869
4870#ifndef PAL
4871 s32 *slot;
4872#endif
4873 int space = GetBoardSpace(held, &page);
4874 int max = PersonalRetMax(page);
4875
4876 if (space < 0 || max <= space) {
4877 ComMenuSePlay(MENU_SOUND_REFUSE);
4878 } else {
4879 slot = &info[space];
4880 int slot_info = *slot;
4881 ShopHaveItemPt->from_page = page;
4882 ShopHaveItemPt->from_slot = space;
4883 int equipped = ShopMenu.board.held_equipped_slot;
4884 int item_no = ShopHaveItemPt->item_no;
4885 PersonalBoardItemCancel();
4886
4887 if (0 <= equipped) {
4888 int chara = WhoIsWeaponEquip(item_no);
4889 ShopUserStatusPt->equipped_weapon_slot[chara] = space % 10;
4890 }
4891
4892 ShopHaveItemPt->slot_state = slot_info;
4893 *slot = held_info;
4894 }
4895
4896 break;
4897 }
4898 }
4899 }
4900 } else if (GamePad.Down(PAD_SQUARE) != 0) {
4901 switch (ShopMenu.board.page) {
4902 case BOARD_PAGE_ITEM: {
4903 ITEM_PACK *pack = &ShopUserStatusPt->item_pack;
4904 SeitonShopItemBoard(pack);
4905 SetMenuTrushMark(pack);
4906 break;
4907 }
4908 case BOARD_PAGE_ATTACH:
4909 SeitonShopAttachBoard((ATTACH_LIST *) ShopUserStatusPt->consumable_items);
4910 break;
4911 }
4912
4913 ComMenuSePlay(MENU_SOUND_CONFIRM);
4914 }
4915
4916#ifdef PAL
4917 // Debug shortcuts: add or take Gilda, and dump the shop board.
4918 if (GamePad.On2(PAD_TRIANGLE)) {
4919 CUserStatus *status = ShopUserStatusPt;
4920 int total = status->money + 1000;
4921
4922 if (total >= 0xFFFF) {
4923 status->money = 0xFFFF;
4924 } else {
4925 status->money = total;
4926 }
4927 }
4928
4929 if (GamePad.On2(PAD_CROSS)) {
4930 CUserStatus *status = ShopUserStatusPt;
4931 int money = status->money;
4932
4933 if (money - 1000 >= 0xFFFF) {
4934 status->money = 0xFFFF;
4935 } else {
4936 status->money += -1000;
4937 }
4938 }
4939
4940 if (GamePad.Down2(PAD_R1)) {
4941 for (int i = 0; i < 30; i++) {
4942 printf(" %d \tis \t\t%d\n", i, ShopBoardInfo[i]);
4943 }
4944 }
4945
4946 if (GamePad.Down2(PAD_R2)) {
4947 int capacity[3] = {100, 60, 40};
4948 int max;
4949
4950 switch (ShopMenu.board.page) {
4951 case BOARD_PAGE_ITEM:
4952 max = capacity[0];
4953 break;
4954 case BOARD_PAGE_WEAPON:
4955 max = capacity[1];
4956 break;
4957 case BOARD_PAGE_ATTACH:
4958 max = capacity[2];
4959 break;
4960 }
4961 }
4962
4963#endif
4964 if (cursor != ShopMenu.board.cursor || old_page != ShopMenu.board.page) {
4965 ComMenuSePlay(MENU_SOUND_CURSOR);
4966 }
4967
4968 int mes_no = 0;
4969 int value = 0;
4970 int name_mes = -1;
4971
4972 if (ShopHaveItemPt->item_no >= ITEM_ATTACH_START) {
4973 COM_ITEM_INFO *item_info = GetCommonItemInfo(ShopHaveItemPt->item_no);
4974 mes_no = item_info != NULL ? item_info->msg + 500 : mes_no;
4975 value = GetAttachVolumeForMsg(ShopHaveAttachPt);
4976
4977 if (ShopHaveItemPt->item_no == ITEM_ATTACH_SYNTHESIS_SPHERE) {
4978 name_mes = GetWeaponMsgNo2(ShopHaveAttachPt->sphere_weapon_no);
4979 }
4980 }
4981
4982 int item_no = -1;
4983 int pos = ShopMenu.board.cursor;
4984 ATTACH_LIST *list;
4985
4986 switch (ShopMenu.side) {
4987 case SHOP_SIDE_CHECK_BUTTON:
4988 mes_no = 0x4B3;
4989 break;
4990 case SHOP_SIDE_STOCK:
4991 item_no = ShopListPt[pos].item_no;
4992
4993 if (item_no >= ITEM_WEAPON_START) {
4994 value = ShopListPt[pos].data.weapon.level;
4995 }
4996
4997 if (item_no >= ITEM_ATTACH_STAT_START && item_no < ITEM_ATTACH_GEM_START) {
4998 list = &ShopListPt[pos].data.attach;
4999 value = GetAttachVolumeForMsg(list);
5000 }
5001
5002 if (item_no == ITEM_ATTACH_SYNTHESIS_SPHERE) {
5003 name_mes = GetWeaponMsgNo2(ShopListPt[pos].data.attach.sphere_weapon_no);
5004 value = ShopListPt[pos].data.attach.sphere_level;
5005 }
5006
5007 break;
5008 case SHOP_SIDE_PERSONAL:
5009 switch (ShopMenu.board.page) {
5010 case BOARD_PAGE_ITEM: {
5011 ITEM_PACK *pack = &ShopUserStatusPt->item_pack;
5012 item_no = pack->item[pos];
5013 break;
5014 }
5015 case BOARD_PAGE_WEAPON: {
5016 CUserStatus *status = ShopUserStatusPt;
5017 WEAPON_HAVE *row;
5018 WEAPON_HAVE *weapon = &(row = status->chara_weapons[pos / 10])[pos % 10];
5019 item_no = weapon->item_no;
5020 value = weapon->level;
5021 break;
5022 }
5023 case BOARD_PAGE_ATTACH: {
5024 list = &((ATTACH_LIST *) ShopUserStatusPt->consumable_items)[pos];
5025
5026 if (list != NULL) {
5027 item_no = list->item_no;
5028
5029 if (item_no > 0) {
5030 value = GetAttachVolumeForMsg(list);
5031
5032 if (list->item_no == ITEM_ATTACH_SYNTHESIS_SPHERE) {
5033 name_mes = GetWeaponMsgNo2(list->sphere_weapon_no);
5034 }
5035 }
5036 }
5037
5038 break;
5039 }
5040 }
5041
5042 break;
5043 }
5044
5045 if (item_no >= ITEM_ATTACH_START) {
5046 COM_ITEM_INFO *item_info = GetCommonItemInfo(item_no);
5047
5048 if (item_info != NULL) {
5049 mes_no = item_info->msg + 500;
5050 }
5051 }
5052
5053 if (CommonMenuMes2.mes_made != mes_no || (name_mes > 0 && CommonMenuMes2.mes_no[0] != name_mes + 100) || CommonMenuMes2.value != value) {
5054 CommonMenuMes2.value_signed = true;
5055 CommonMenuMes2.value_show = false;
5056 CommonMenuMes2.value = value;
5057
5058 if (name_mes > 0) {
5059 CommonMenuMes2.mes_no[0] = name_mes + 100;
5060 }
5061
5062 if (mes_no <= 500) {
5063 mes_no = 0;
5064 }
5065
5066 CommonMenuMes2.mes_made = -1;
5067 CommonMenuMes2.MakeMesWin(mes_no);
5068 }
5069
5070 break;
5071 }
5072 }
5073 }
5074
5075 return result;
5076}
5077
5078void ItemShopDraw2() {
5079 int cur_x;
5080 int pos_y;
5081 int count;
5082 int top_row;
5083 int state;
5084 int text_x;
5085 int text_y;
5086
5087 setbilinear(0);
5088 MenuWorldTrans(&MenuCamera);
5089 int bright = 0x40;
5090
5091 switch (ShopMenu.talk_mode) {
5092 case SHOP_TALK_FADE_IN:
5093 bright = 0x80 - ShopMenu.step_count * 3;
5094 break;
5095 case SHOP_TALK_FADE_OUT:
5096 bright = ShopMenu.step_count * 4 + 0x40;
5097 break;
5098 }
5099
5100 if (bright < 0x40) {
5101 bright = 0x40;
5102 }
5103
5104 if (bright > 0x80) {
5105 bright = 0x80;
5106 }
5107
5108 FrameImageDraw(bright, 0x80);
5109
5110 if (ShopMenu.ready != 0) {
5111 MenuTextureReload(ShopMenu.tex_block);
5112 count = PersonalRetMax(ShopMenu.board.page);
5113 pos_y = 0x7F - ShopMenu.board.top_row * 0x28;
5114 ShopMenu.board.y += ((float) pos_y - ShopMenu.board.y) / 4.0f;
5115 cur_x = 0x168;
5116 pos_y = (int) ShopMenu.board.y;
5117 int mark = 0;
5118
5119 if (ShopMenu.board.page == BOARD_PAGE_WEAPON) {
5120 mark = 2;
5121 }
5122
5123 DrawPerBoardDraw(mark, count, 0x168, pos_y, 0x81, 0x121, PerBoardTex, 0x80);
5124 CommonIconDraw(ShopMenu.board.page, count, 0x16A, pos_y + 6, 0x81, 0x121, 0x80);
5125 PersonalBoardOptionDraw(ShopMenu.board.page, count, 0x154, 0x78, PerBoardTex, 0x80);
5126 CommonTrushDraw(0x232, 0x10C, 0x80);
5127 CommonMoneyBoardDraw(0x163, 0x120, ShopUserStatusPt->money, 0x80);
5128 DrawMoneyCheckBoard2(0x1C8, 0x120, 0x80);
5129 DrawItemShopBoard2(0x32, 0x78, 0x80);
5130 ChargeShopLRDraw(0x80);
5131 ShopDataMove.IconAutoMoveDraw();
5132 ShopDataMove.IconAutoMove(ChargeOrShopFlag, 0);
5133
5134 switch (ShopMenu.side) {
5135 case SHOP_SIDE_CHECK_BUTTON:
5136 case SHOP_SIDE_STOCK:
5137 cur_x = 0x22;
5138 top_row = ShopMenu.stock_top_row;
5139 break;
5140 case SHOP_SIDE_PERSONAL:
5141 cur_x = 0x144;
5142 top_row = ShopMenu.board.top_row;
5143 break;
5144 }
5145
5146 state = 0;
5147
5148 if (ShopHaveItemPt->item_no >= ITEM_ATTACH_START) {
5149 state = 2;
5150 } else {
5151 switch (ShopMenu.side) {
5152 case SHOP_SIDE_PERSONAL:
5153 state = SearchBoardNowPosItemExist(ShopMenu.board.page, ShopMenu.board.cursor);
5154
5155 if (state < ITEM_ATTACH_START) {
5156 state = 0;
5157 } else {
5158 state = 1;
5159 }
5160
5161 break;
5162 case SHOP_SIDE_STOCK:
5163 if (ShopListPt[ShopMenu.board.cursor].item_no > ITEM_ATTACH_START) {
5164 state = 1;
5165 } else {
5166 state = 0;
5167 }
5168
5169 break;
5170 case SHOP_SIDE_CHECK_BUTTON:
5171 break;
5172 }
5173 }
5174
5175 int on_button = 0;
5176
5177 switch (ShopMenu.side) {
5178 case SHOP_SIDE_CHECK_BUTTON:
5179 on_button = 1;
5180 break;
5181 }
5182
5183 ShopCurDraw(cur_x, 0x84, ShopMenu.board.cursor, top_row, on_button, state, 0x80);
5184 DrawShopIcon(0x4C, 0x2A, 0, 0x80);
5185
5186 switch (ShopMenu.side) {
5187 case SHOP_SIDE_STOCK: {
5188 int cursor = ShopMenu.board.cursor;
5189 int item_no = ShopListPt[cursor].item_no;
5190
5191 if (item_no >= ITEM_ATTACH_START) {
5192 int selling = 0;
5193
5194 if (ShopBoardInfo[cursor] == SHOP_SLOT_PLAYER_ITEM) {
5195 selling = 1;
5196 }
5197
5198 int money = CalItemMoney(item_no, selling);
5199
5200 if (item_no >= ITEM_WEAPON_START) {
5201 money += WeaponCalMoney((WEAPON_HAVE *) &ShopListPt[cursor].data, selling);
5202 }
5203
5204 if (money < 0) {
5205 money = 1;
5206 }
5207
5208 cur_x = cursor % 5 * 0x28 + 0x4A;
5209 pos_y = (int) (6.0f + ShopMenu.stock_y + (float) (cursor / 5 * 0x28));
5210 DrawBigSellTicket(selling, money, cur_x, pos_y, 0x80);
5211 }
5212
5213 break;
5214 }
5215 case SHOP_SIDE_PERSONAL:
5216 if (ShopMenu.talk_mode == SHOP_TALK_SELL_PROMPT) {
5217 int item_no;
5218
5219 switch (ShopMenu.board.page) {
5220 case BOARD_PAGE_ITEM: {
5221 CUserStatus *status = ShopUserStatusPt;
5222 ITEM_PACK *pack = &status->item_pack;
5223 item_no = pack->item[ShopMenu.board.cursor];
5224 break;
5225 }
5226 case BOARD_PAGE_ATTACH: {
5227 CUserStatus *status = ShopUserStatusPt;
5228 DNG_CONSUMABLE *attach = status->consumable_items;
5229 item_no = attach[ShopMenu.board.cursor].id;
5230 break;
5231 }
5232 case BOARD_PAGE_WEAPON: {
5233 int chara_no = ShopMenu.board.cursor / 10;
5234 CUserStatus *status = ShopUserStatusPt;
5235 WEAPON_HAVE *row = status->chara_weapons[chara_no];
5236 item_no = row[ShopMenu.board.cursor % 10].item_no;
5237 break;
5238 }
5239 }
5240
5241 int ticket_y = (int) (6.0f + ShopMenu.board.y);
5242 int money = CalItemMoney(item_no, 1);
5243
5244 if (item_no >= ITEM_WEAPON_START) {
5245 int chara_no = ShopMenu.board.cursor / 10;
5246 CUserStatus *status = ShopUserStatusPt;
5247 WEAPON_HAVE *row = status->chara_weapons[chara_no];
5248 money += WeaponCalMoney(&row[ShopMenu.board.cursor % 10], 1);
5249 }
5250
5251 if (money <= 0) {
5252 money = 1;
5253 }
5254
5255 DrawBigSellTicket(1, money, ShopMenu.board.cursor % 5 * 0x28 + 0x16A, ticket_y + ShopMenu.board.cursor / 5 * 0x28, 0x80);
5256 }
5257
5258 break;
5259 }
5260
5261 DrawSellTicket22(0x16A, (int) (6.0f + ShopMenu.board.y), 0x81, 0x121, 0x80);
5262 MenuHelpWinDraw((int) ShopHelpWinPos[0], (int) ShopHelpWinPos[1], ShopHelpWinW, ShopHelpWinH, 0x80);
5263 GetMainMenuRightHelpMsgLangOffset(text_x, text_y);
5264 CommonMenuMes2.text_x = (int) (ShopHelpWinPos[0] + text_x);
5265 CommonMenuMes2.text_y = (int) (ShopHelpWinPos[1] + text_y);
5266 }
5267
5268 if (ShopMenu.person_state == 2) {
5269 ShopPersonDraw(ShopMenu.shop_no);
5270 }
5271
5272 if (ShopMenu.ready != 0) {
5273 MenuTextureReload(CommonMenuMes2.tex_block);
5274 CommonMenuMes2.Step();
5275 CommonMenuMes2.DrawMesWin();
5276
5277 if (ShopHaveItemPt->item_no < ITEM_ATTACH_START) {
5278#ifdef PAL
5279 s8 plate[3] = {6, 7, 8};
5280 int mes_no = plate[ShopMenu.side] + 0x4B0;
5281
5282#else
5283 int plate[3] = {0x4B6, 0x4B7, 0x4B8};
5284 int mes_no = plate[ShopMenu.side];
5285
5286#endif
5287 if (AtoraNameMes.mes_made != mes_no) {
5288 AtoraNameMes.MakeMesWin(mes_no);
5289 }
5290
5291 AtoraNameMes.stay_frame = true;
5292 AtoraNameMes.text_x = 0xB4;
5293 AtoraNameMes.text_y = SCREEN_HEIGHT - 0x58;
5294
5295#ifdef PAL
5296 // The third plate draws further left in language 6.
5297 if (GetMenuLangFlag() == LANG_SPANISH && mes_no == 0x4B8) {
5298 AtoraNameMes.text_x -= 0x12;
5299 }
5300
5301#endif
5302 AtoraNameMes.Step();
5303 AtoraNameMes.DrawMesWin();
5304 }
5305
5306 switch (ShopMenu.talk_mode) {
5307 case SHOP_TALK_BUY_PROMPT:
5308 case SHOP_TALK_SELL_PROMPT: {
5309 s16 prompt[2] = {0x4B4, 0x4B5};
5310 int mes_no = prompt[ShopMenu.talk_mode - SHOP_TALK_BUY_PROMPT];
5311
5312 if (CommonMenuMes1.mes_made != mes_no) {
5313 CommonMenuMes1.MakeMesWin(mes_no);
5314 }
5315
5316 s8 offset[7][2] = {
5317 {0x1E, 0x32},
5318 {0x18, 0x32},
5319 {0x18, 0x32},
5320 {0x18, 0x32},
5321 {0x18, 0x32},
5322 {0x18, 0x32},
5323 {0x18, 0x32}
5324 };
5325 CommonMenuMes1.text_x = offset[ShopMenu.lang][0] + 0x12C;
5326 CommonMenuMes1.text_y = 0xBE;
5327
5328 if (ShopMenu.talk_mode == SHOP_TALK_SELL_PROMPT) {
5329 CommonMenuMes1.text_x = offset[ShopMenu.lang][1] + 0x64;
5330 }
5331
5332 CommonMenuMes1.stay_frame = true;
5333 CommonMenuMes1.Step();
5334 CommonMenuMes1.DrawMesWin();
5335 break;
5336 }
5337 default:
5338 CommonMenuMes1.stay_frame = false;
5339 break;
5340 }
5341 }
5342
5343 ShopModelMsgFunc(SHOP_KIND_ITEM);
5344 ShopFadeoutDraw();
5345 setbilinear(1);
5346}
5347
5355FISH_EXCHANGE_ITEM exitemlst[35] = {
5356 {ITEM_ANTIDOTE_DRINK, 5 },
5357 {ITEM_HOLY_WATER, 5 },
5358 {ITEM_SOAP, 5 },
5359 {ITEM_MIGHTY_HEALING, 15 },
5360 {ITEM_ATTACH_DINOSLAYER, 50 },
5361 {ITEM_ATTACH_UNDEAD_BUSTER, 50 },
5362 {ITEM_ATTACH_SEA_KILLER, 50 },
5363 {ITEM_ATTACH_STONE_BREAKER, 50 },
5364 {ITEM_ATTACH_PLANT_BUSTER, 50 },
5365 {ITEM_ATTACH_BEAST_BUSTER, 50 },
5366 {ITEM_ATTACH_SKY_HUNTER, 50 },
5367 {ITEM_ATTACH_METALBREAKER, 50 },
5368 {ITEM_ATTACH_MIMIC_BREAKER, 50 },
5369 {ITEM_ATTACH_MAGE_SLAYER, 50 },
5370 {ITEM_ATTACH_GARNET, 100 },
5371 {ITEM_ATTACH_AMETHYST, 100 },
5372 {ITEM_ATTACH_AQUAMARINE, 100 },
5373 {ITEM_ATTACH_DIAMOND, 100 },
5374 {ITEM_ATTACH_EMERALD, 100 },
5375 {ITEM_ATTACH_PEARL, 100 },
5376 {ITEM_ATTACH_RUBY, 100 },
5377 {ITEM_ATTACH_PERIDOT, 100 },
5378 {ITEM_ATTACH_SAPPHIRE, 100 },
5379 {ITEM_ATTACH_OPAL, 100 },
5380 {ITEM_ATTACH_TOPAZ, 100 },
5381 {ITEM_ATTACH_TURQUOISE, 100 },
5382 {ITEM_WEAPON_TSUKIKAGE, 1100},
5383 {ITEM_WEAPON_MATADOR, 1400},
5384 {ITEM_WEAPON_MAGICAL_HAMMER, 1800},
5385 {ITEM_WEAPON_FAIRY_S_RING, 1300},
5386 {ITEM_WEAPON_SCORPION, 1400},
5387 {ITEM_WEAPON_BLESSING_GUN, 1500},
5388 {ITEM_WEAPON_MARDAN_EINS, 2500},
5389 {ITEM_BOMB_NUTS, 2 },
5390 {ITEM_POISONOUS_APPLE, 2 },
5391};
5392
5393static FISH_EXCHANGE_ITEM *GetExchangeItemList(int index) {
5394 return &exitemlst[index];
5395}
5396
5397int GetMardanGareyanFlag() {
5398 return SaveData->GetMardanGareyanFlag();
5399}
5400
5401void SetAlreadyGetMardanWeapon(int taken) {
5402 SaveData->SetGameFlag(0xCA, taken);
5403}
5404
5405void SetFishMardanGarayanNum(int count) {
5406 int total = count + GetFishMardanGarayanNum();
5407
5408 if (total < 0) {
5409 total = 0;
5410 }
5411
5412 if (total > 10000) {
5413 total = 10000;
5414 }
5415
5416 SaveData->SetGameIntFlag(0x14, total);
5417 printf("now mardan num(IntFlag):\t%d\n", GetFishMardanGarayanNum());
5418}
5419
5420int GetFishMardanGarayanNum() {
5421 return SaveData->GetGameIntFlag(0x14);
5422}
5423
5424void ClearFishMardanGarayanNum() {
5425 SaveData->SetGameIntFlag(0x14, 0);
5426}
5427
5436static int AlreadyGetMardanWeapon() {
5437 int flag = SaveData->GetGameFlag(0xCA);
5438
5439 if (flag == 0) {
5440 if (GetMardanGareyanFlag() > 0) {
5441 return 1;
5442 }
5443
5444 return 2;
5445 }
5446
5447 if (flag == 1) {
5448 return 0;
5449 }
5450
5451 return flag;
5452}
5453
5454void InitFishingExchange(u_long128 *buffer, int *tex_block, int mode) {
5455 FishMenu.buffer = (u_long128 *) (EdMenuBuffer.base + EdMenuBuffer.used * 16);
5456 FishMenu.buffer = MenuCalcBufAlignment(FishMenu.buffer);
5457 FishMenu.tex_block = tex_block[0];
5458 FishMenu.tex_block2 = tex_block[1];
5459 FishMenu.mode = mode;
5460 StartReadBG();
5461 FishMenu.buffer = FishMenu.buffer + (LoadFileBGMenuData("fishmenu.pac", FishMenu.buffer) >> 4) + 1;
5462 FishMenu.buffer = MenuCalcBufAlignment(FishMenu.buffer);
5463 FishMenu.ready = 0;
5464 FishMenu.confirm = 1;
5465 FishMenu.cursor = 0;
5466 FishMenu.top = 0;
5467 FishMenu.fade_mode = FISH_EXCHANGE_FADE_IN;
5468 FishMenu.fade_count = 0;
5469 FishMenu.point = SaveData->GetFishingPoint();
5470
5471 if (FishMenu.point < 0) {
5472 SaveData->SetFishingPoint(0);
5473 FishMenu.point = SaveData->GetFishingPoint();
5474 }
5475
5476 if (FishMenu.point > 9999) {
5477 FishMenu.point = 9999;
5478 }
5479
5480 StayTex = TexManager.GetTexture("stayframe", -1);
5481 GamePad.SetAutoRepeat(PAD_DPAD, 0x1E, 5);
5482 GamePad.MenuModeOn(0x78);
5483}
5484
5485char FishFrameImage[] __attribute__((section(".rodata"))) = "#frame_image#640#" SCREEN_HEIGHT_STR "#4";
5486
5494static int FishMenuTextureLoad() {
5495 int done = 0;
5496
5497 if (FishMenu.ready == 0) {
5498 if (ReadBGSync() == 0) {
5499 BG_READ_INFO *file = GetReadBGFile(0);
5500 LOADTEXTURE_INFO2 texture[3] = {
5501 {FishFrameImage, 0, 0},
5502 {NULL, 0, 0},
5503 {NULL, 0, 0},
5504 };
5505 texture[0].block_no = FishMenu.tex_block;
5506 texture[1].block_no = FishMenu.tex_block;
5507 texture[1].name = (char *) GetPackFile((u_int *) file->buffer, "fishing.img", NULL);
5508 TexManager.DeleteTextureBlock(FishMenu.tex_block);
5509 TexManager.CleanUpTextureList();
5510 TexManager.LoadTextureBlockEX(-1, texture);
5511 FishMenuTex = TexManager.GetTexture("fishbrd", -1);
5512 WepIcon = TexManager.GetTexture("wepicon", -1);
5513 ItemIcon = TexManager.GetTexture("itemicon", -1);
5514 InitMenuMesSet(MENU_MES_SET_ALLMENU, (short *) GetPackFile((u_int *) file->buffer, FishMessageFile, NULL));
5515 CommonMenuMes2.mes_made = -1;
5516 AtoraNameMes.Preset(MES_PRESET_SYSTEM);
5517
5518 for (int i = 0; i < 5; i++) {
5519 AtoraNameMes.mes_no[i] = GetExchangeItemList(i)->item_no + 100;
5520 }
5521
5522 AtoraNameMes.narrow_gaiji = true;
5523 AtoraNameMes.style = MES_EDGE_DOUBLE;
5524 AtoraNameMes.value_signed = false;
5525 AtoraNameMes.value_show = true;
5526 AtoraNameMes.mes_made = -1;
5527 AtoraNameMes.MakeMesWin(0xC8);
5528 AtoraNameMes.Step();
5529 FishMenu.ready = 1;
5530 CommonMenuMes3.value_signed = false;
5531 CommonMenuMes3.value_show = true;
5532 CommonMenuMes3.stay_frame = true;
5533 CommonMenuMes3.value = 0;
5534 int digits = GetNumberKeta(0);
5535 CommonMenuMes3.mes_made = -1;
5536 CommonMenuMes3.MakeMesWin(digits + 0xCD);
5537 FishMenu.cursor_y = 0x7E;
5538 done = 1;
5539 }
5540 } else {
5541 done = 1;
5542 }
5543
5544 return done;
5545}
5546
5547char FishMessageFile[] __attribute__((section(".rodata"))) = "fishmes.bin";
5548
5549int FishingExchangeKey() {
5550 int result = 0;
5551
5552 ReadBG();
5553
5554#ifdef PAL
5555 // Debug shortcut: adds a Mardan Garayan catch.
5556 if (DebugMode && GamePad.Down2(PAD_TRIANGLE)) {
5557 s32 &caught = SaveData->mardan_garayan_caught;
5558
5559 caught++;
5560 SetFishMardanGarayanNum(1);
5561 }
5562
5563#endif
5564 int mardan = AlreadyGetMardanWeapon();
5565 int party = SaveData->GetDngStatus()->party_size;
5566
5567 if (party <= 0) {
5568 party = 1;
5569 }
5570
5571 int last_prize = party + 0x19;
5572 int last_top = party + 0x16;
5573
5574 if (mardan == 1) {
5575 last_prize++;
5576 last_top++;
5577 }
5578
5579 int count;
5580
5581 switch (FishMenu.fade_mode) {
5582 case FISH_EXCHANGE_FADE_IN:
5583 FishMenuTextureLoad();
5584 FishMenu.fade_count++;
5585
5586 if (FishMenu.ready != 0 && FishMenu.fade_count > 32) {
5587 FishMenu.fade_mode = FISH_EXCHANGE_SELECT;
5588 }
5589
5590 break;
5591 case FISH_EXCHANGE_FADE_OUT:
5592 FishMenu.fade_count++;
5593
5594 if (FishMenu.fade_count > 32) {
5595 result = 1;
5596 }
5597
5598 break;
5599 case FISH_EXCHANGE_SELECT: {
5600 int cursor = FishMenu.cursor;
5601 int top = FishMenu.top;
5602
5603 if (GamePad.Down(PAD_R2 | PAD_R1 | PAD_RIGHT) != 0) {
5604 FishMenu.top += 5;
5605 FishMenu.cursor += 5;
5606 }
5607
5608 if (GamePad.Down(PAD_L2 | PAD_L1 | PAD_LEFT) != 0) {
5609 FishMenu.top -= 5;
5610 FishMenu.cursor -= 5;
5611
5612 if (FishMenu.cursor < 0 || FishMenu.top < 0) {
5613 FishMenu.cursor = 0;
5614 FishMenu.top = 0;
5615 }
5616 }
5617
5618 if (GamePad.Down(PAD_UP) != 0) {
5619 FishMenu.cursor--;
5620
5621 if (FishMenu.cursor < 0) {
5622 FishMenu.cursor = 0;
5623 }
5624
5625 if (FishMenu.cursor < FishMenu.top) {
5626 FishMenu.top--;
5627 }
5628
5629 if (FishMenu.top < 0) {
5630 FishMenu.top = 0;
5631 FishMenu.cursor = 0;
5632 }
5633 }
5634
5635 if (GamePad.Down(PAD_DOWN) != 0) {
5636 FishMenu.cursor++;
5637
5638 if (last_prize < FishMenu.cursor) {
5639 FishMenu.cursor = last_prize;
5640 }
5641
5642 if (FishMenu.top < FishMenu.cursor - 4) {
5643 FishMenu.top++;
5644
5645 if (last_top < FishMenu.top) {
5646 FishMenu.top = last_top - 1;
5647 }
5648 }
5649 }
5650
5651#ifdef PAL
5652 // Debug shortcut: raises or lowers the points to spend.
5653 if (DebugMode) {
5654 if (GamePad.On2(PAD_CROSS) && FishMenu.point < 9999) {
5655 FishMenu.point++;
5656 }
5657
5658 if (GamePad.On2(PAD_CIRCLE) && FishMenu.point > 0) {
5659 FishMenu.point--;
5660 }
5661 }
5662
5663#endif
5664 if (last_prize < FishMenu.cursor) {
5665 FishMenu.cursor = last_prize;
5666 }
5667
5668 if (last_top < FishMenu.top) {
5669 FishMenu.top = last_top - 1;
5670 }
5671
5672 if (cursor != FishMenu.cursor) {
5673 ComMenuSePlay(MENU_SOUND_CURSOR);
5674 }
5675
5676 FISH_EXCHANGE_ITEM *prize = GetExchangeItemList(FishMenu.cursor);
5677
5678 if (mardan == 1 && FishMenu.cursor == last_prize) {
5679 prize = GetExchangeItemList(0x20);
5680 }
5681
5682 if (prize != NULL) {
5683 COM_ITEM_INFO *info = GetCommonItemInfo(prize->item_no);
5684
5685 if (info != NULL) {
5686 int mes_no = info->msg + 500;
5687
5688 if (CommonMenuMes2.mes_made != mes_no) {
5689 CommonMenuMes2.MakeMesWin(mes_no);
5690 }
5691 }
5692 }
5693
5694 if (GamePad.Down(PAD_CROSS) != 0) {
5695 CUserStatus *status = (CUserStatus *) SaveData->GetDngStatus();
5696 int full = 0;
5697 int kind = WhatIsKindofItem(prize->item_no);
5698 count = 0;
5699
5700 switch (kind) {
5701 case BOARD_PAGE_ITEM: {
5702 int i;
5703 int k;
5704 ITEM_PACK *pack = &status->item_pack;
5705
5706 for (i = 0; i < 3; i++) {
5707 count += pack->quick_item_qty[i];
5708 }
5709
5710 for (k = 0; k < pack->num; k++) {
5711 if (pack->item[k] >= ITEM_DUNGEON_START) {
5712 count++;
5713 }
5714 }
5715
5716 if (count >= pack->num) {
5717 full = 1;
5718 }
5719
5720 break;
5721 }
5722 case BOARD_PAGE_WEAPON: {
5723 int i;
5724 int owner = WhoIsWeaponEquip(prize->item_no);
5725 int held = 0;
5726 WEAPON_HAVE *weapons = status->chara_weapons[owner];
5727
5728 for (i = 0; i < 10; i++) {
5729 if (weapons[i].item_no >= ITEM_WEAPON_START) {
5730 held++;
5731 }
5732 }
5733
5734 if (held >= 10) {
5735 full = 1;
5736 }
5737
5738 break;
5739 }
5740 case BOARD_PAGE_ATTACH: {
5741 int held;
5742 DNG_CONSUMABLE *attach = status->consumable_items;
5743 int entry;
5744 held = 0;
5745
5746 for (; count < 40; count++) {
5747 entry = count * sizeof(DNG_CONSUMABLE);
5748 entry = (int) attach + entry;
5749
5750 if (((DNG_CONSUMABLE *) entry)->id >= ITEM_ATTACH_START) {
5751 held++;
5752 }
5753 }
5754
5755 if (held >= 40) {
5756 full = 1;
5757 }
5758
5759 break;
5760 }
5761 }
5762
5763 if (prize->price > FishMenu.point) {
5764 FishMenu.fade_mode = FISH_EXCHANGE_REFUSE;
5765 FishMenu.warning = 14;
5766 ComMenuSePlay(MENU_SOUND_REFUSE);
5767 } else if (full != 0) {
5768 FishMenu.warning = kind;
5769 FishMenu.fade_mode = FISH_EXCHANGE_REFUSE;
5770 ComMenuSePlay(MENU_SOUND_REFUSE);
5771 } else {
5772 FishMenu.confirm = 1;
5773 FishMenu.cursor_y = FishMenu.confirm * 0x24 + 0x102;
5774 FishMenu.fade_mode = FISH_EXCHANGE_CONFIRM;
5775 ComMenuSePlay(MENU_SOUND_CONFIRM);
5776 }
5777 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
5778 FishMenu.fade_mode = FISH_EXCHANGE_FADE_OUT;
5779 FishMenu.fade_count = 0;
5780 ComMenuSePlay(MENU_SOUND_REFUSE);
5781 }
5782
5783 if (top != FishMenu.top) {
5784 FISH_EXCHANGE_ITEM *entry = GetExchangeItemList(FishMenu.top);
5785
5786 for (int i = 0; i < 5; i++) {
5787 if (mardan == 1 && FishMenu.cursor == FishMenu.top + i && FishMenu.cursor == last_prize) {
5788 entry = GetExchangeItemList(0x20);
5789 }
5790
5791 if (entry == NULL) {
5792 printf("getinfo is NULL\n");
5793 } else {
5794 COM_ITEM_INFO *info = GetCommonItemInfo(entry->item_no);
5795
5796 if (info != NULL) {
5797 AtoraNameMes.mes_no[i] = info->msg + 100;
5798 entry++;
5799 }
5800 }
5801 }
5802
5803 AtoraNameMes.mes_made = -1;
5804 AtoraNameMes.MakeMesWin(0xC8);
5805 }
5806
5807 break;
5808 }
5809 case FISH_EXCHANGE_CONFIRM: {
5810 if (GamePad.Down(PAD_UP | PAD_DOWN) != 0) {
5811 if (FishMenu.confirm != 0) {
5812 FishMenu.confirm = 0;
5813 } else {
5814 FishMenu.confirm = 1;
5815 }
5816
5817 ComMenuSePlay(MENU_SOUND_CURSOR);
5818 }
5819
5820 FISH_EXCHANGE_ITEM *prize;
5821
5822 if (GamePad.Down(PAD_CROSS) != 0) {
5823 int enough = 1;
5824 prize = GetExchangeItemList(FishMenu.cursor);
5825
5826 if (mardan == 1 && FishMenu.cursor == last_prize) {
5827 prize = GetExchangeItemList(0x20);
5828 }
5829
5830 if (prize == NULL) {
5831 ComMenuSePlay(MENU_SOUND_REFUSE);
5832 break;
5833 }
5834
5835 int price = prize->price;
5836
5837 if (FishMenu.point < price) {
5838 enough = 0;
5839 }
5840
5841 if (FishMenu.confirm == 0) {
5842 if (enough != 0) {
5843 ComMenuSePlay(SE_PURCHASE);
5844 ((CDngStatusData *) SaveData->GetDngStatus())->GetItem(prize->item_no, 0);
5845 FishMenu.point -= price;
5846
5847 if (prize->item_no == ITEM_WEAPON_MARDAN_EINS) {
5848 SetAlreadyGetMardanWeapon(1);
5849 ClearFishMardanGarayanNum();
5850 FishMenu.top--;
5851 FishMenu.cursor--;
5852 }
5853
5854 if (FishMenu.point < 0) {
5855 FishMenu.point = 0;
5856 }
5857 } else {
5858 ComMenuSePlay(MENU_SOUND_REFUSE);
5859 }
5860 } else {
5861 ComMenuSePlay(MENU_SOUND_REFUSE);
5862 }
5863
5864 FishMenu.cursor_y = (FishMenu.cursor - FishMenu.top) * 0x22 + 0x7E;
5865 FishMenu.fade_mode = FISH_EXCHANGE_SELECT;
5866 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
5867 ComMenuSePlay(MENU_SOUND_REFUSE);
5868 FishMenu.fade_mode = FISH_EXCHANGE_SELECT;
5869 }
5870
5871 prize = GetExchangeItemList(FishMenu.cursor);
5872
5873 if (mardan == 1 && FishMenu.cursor == last_prize) {
5874 prize = GetExchangeItemList(0x20);
5875 }
5876
5877 if (prize != NULL) {
5878 COM_ITEM_INFO *info = GetCommonItemInfo(prize->item_no);
5879
5880 if (info != NULL) {
5881 int msg = info->msg;
5882
5883 if (CommonMenuMes1.mes_made != 0xCA || CommonMenuMes1.mes_no[0] != msg + 100 || CommonMenuMes1.values[0] != prize->price) {
5884 CommonMenuMes1.mes_made = -1;
5885 CommonMenuMes1.mes_no[0] = msg + 100;
5886 CommonMenuMes1.values[0] = prize->price;
5887 CommonMenuMes1.MakeMesWin(0xCA);
5888 }
5889 }
5890 }
5891
5892 break;
5893 }
5894 case FISH_EXCHANGE_REFUSE: {
5895 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
5896 FishMenu.fade_mode = FISH_EXCHANGE_SELECT;
5897 ComMenuSePlay(MENU_SOUND_REFUSE);
5898 }
5899
5900 if (CommonMenuMes1.mes_made != FishMenu.warning + 0xCB) {
5901 CommonMenuMes1.MakeMesWin(FishMenu.warning + 0xCB);
5902 }
5903
5904 break;
5905 }
5906 }
5907
5908 CursorVibeCnt++;
5909
5910 if (CursorVibeCnt >= 0x066FF300) {
5911 CursorVibeCnt = 0;
5912 }
5913
5914 return result;
5915}
5916
5924static void FishImageIconDraw(int x, int y, int width, int alpha) {
5925 DrawMenu2DSprite(FishMenuTex, CRect_i_(x, y, width, 0x28), CRect_i_(0, 0xD0, width, 0x28), alpha);
5926}
5927
5931static inline float AddOffset(float base, float offset) {
5932 return base + offset;
5933}
5934
5942static void FishExchangeItemDraw(int x, int y, int alpha) {
5943 int last_prize;
5944 int pos_y;
5945 float win_x;
5946 float win_y;
5947 float win_h;
5948 float win_w;
5949 int text_x;
5950 int text_y;
5951 int i;
5952 int row;
5953
5954 MenuTextureReload(FishMenu.tex_block);
5955 int mardan = AlreadyGetMardanWeapon();
5956 int party = SaveData->GetDngStatus()->party_size;
5957
5958 if (party <= 0) {
5959 party = 1;
5960 }
5961
5962 last_prize = party + 0x19;
5963
5964 if (mardan == 1) {
5965 last_prize++;
5966 }
5967
5968 DrawMenu2DSprite(FishMenuTex, CRect_i_(x, y, 0x160, 0xD0), CRect_i_(0, 0, 0x160, 0xD0), alpha);
5969 float rows = last_prize;
5970 int bar_x = x + 0x144;
5971 float step = 126.0f / rows;
5972 pos_y = (int) AddOffset((float) (y + 0x28), FishMenu.top * step);
5973 float length = 630.0f / rows - 8.0f;
5974 CRect_i_ source(0xF0, 0xD0, 8, 4);
5975 DrawMenu2DSprite(FishMenuTex, CRect_i_(bar_x, pos_y, 8, 4), source, alpha);
5976 source.y += 4;
5977 DrawMenu2DSprite(FishMenuTex, CRect_i_(bar_x, pos_y + 4, 8, (int) length), source, alpha);
5978 source.y += 4;
5979 DrawMenu2DSprite(FishMenuTex, CRect_i_(bar_x, (int) ((float) (pos_y + 4) + length), 8, 4), source, alpha);
5980 x = (int) (x + 0x16);
5981 pos_y = y + 0x14;
5982
5983 for (i = 0; i < 5; i++, pos_y += 0x22) {
5984 FISH_EXCHANGE_ITEM *prize = GetExchangeItemList(FishMenu.top + i);
5985
5986 if (mardan == 1 && i == 4 && FishMenu.top + 4 == last_prize) {
5987 prize = GetExchangeItemList(0x20);
5988 }
5989
5990 DrawIconParts(prize->item_no, x, pos_y, y, y + 0xCE, alpha, 0);
5991 DrawMenu2DSprite(FishMenuTex, CRect_i_(x + 0x104, pos_y + 8, 0x20, 0x14), CRect_i_(0x1E0, 0xEC, 0x20, 0x14), alpha);
5992#ifdef PAL
5993#ifdef PAL
5994 RECT digits = {0x140, 0xEA, 0x10, 0x16};
5995#else
5996 RECT digits = {0x160, 0xEA, 0x10, 0x16};
5997#endif
5998#else
5999 RECT digits = {0x140, 0xEA, 0x10, 0x16};
6000#endif
6001 DrawMenuNumber(prize->price, x + 0x106, pos_y + 6, FishMenuTex, digits, 1, alpha);
6002
6003 if (i >= 0 && i < 10) {
6004 AtoraNameMes.line_pos[i].x = x + 0x24;
6005 AtoraNameMes.line_pos[i].y = pos_y + 4;
6006 }
6007 }
6008
6009 row = FishMenu.cursor - FishMenu.top;
6010 int target_y = y + 0x14 + row * 0x22;
6011 int cursor_x = x - 0x1C;
6012
6013 if (FishMenu.fade_mode == FISH_EXCHANGE_CONFIRM) {
6014 cursor_x = 0xF2;
6015 target_y = (FishMenu.confirm << 5) + 0x102;
6016 }
6017
6018 FishMenu.cursor_y += (int) ((float) (target_y - FishMenu.cursor_y) / 4.0f);
6019
6020 if (abs(FishMenu.cursor_y - target_y) < 2) {
6021 FishMenu.cursor_y = target_y;
6022 }
6023
6024 int cursor_y = FishMenu.cursor_y;
6025 MenuTextureReload(CommonMenuMes2.tex_block);
6026 GetMainMenuRightHelpWinLangOffset(win_x, win_y, win_w, win_h);
6027 MenuHelpWinDraw((int) win_x, (int) win_y, win_w, win_h, 0x80);
6028 GetMainMenuRightHelpMsgLangOffset(text_x, text_y);
6029 CommonMenuMes2.edge_alpha = alpha;
6030 CommonMenuMes2.text_x = (int) (win_x + text_x);
6031 CommonMenuMes2.text_y = (int) (win_y + text_y);
6032 CommonMenuMes2.Step();
6033 CommonMenuMes2.DrawMesWin();
6034 AtoraNameMes.edge_alpha = alpha;
6035 AtoraNameMes.Step();
6036 AtoraNameMes.DrawMesWin();
6037 int point = FishMenu.point;
6038
6039 if (CommonMenuMes3.value != point) {
6040 CommonMenuMes3.value = point;
6041 int digits = GetNumberKeta(point);
6042 CommonMenuMes3.mes_made = -1;
6043 CommonMenuMes3.MakeMesWin(digits + 0xCD);
6044 }
6045
6046 CommonMenuMes3.edge_alpha = alpha;
6047 CommonMenuMes3.text_x = 0x46;
6048#ifdef PAL
6049 CommonMenuMes3.text_y = 0x160;
6050#else
6051 CommonMenuMes3.text_y = 0x140;
6052#endif
6053 CommonMenuMes3.Step();
6054 CommonMenuMes3.DrawMesWin();
6055
6056 if (FishMenu.fade_mode == FISH_EXCHANGE_CONFIRM || FishMenu.fade_mode == FISH_EXCHANGE_REFUSE) {
6057 AllFadeForMenu(0x40);
6058
6059 if (FishMenu.fade_mode == FISH_EXCHANGE_CONFIRM) {
6060 CRect_i_ dest(0x110, 0x102, 0x60, 0x1F);
6061 CRect_i_ window(0x1A0, 0, 0x60, 0x20);
6062 MenuTextureReload(FishMenu.tex_block);
6063 DrawMenu2DSprite(FishMenuTex, dest, window, 0x80);
6064 dest.y += 0x20;
6065 window.y = 0x20;
6066 DrawMenu2DSprite(FishMenuTex, dest, window, 0x80);
6067 CommonMenuMes1.auto_pos = MES_POS_CENTRE;
6068 } else {
6069 CommonMenuMes1.auto_pos = MES_POS_CENTRE;
6070 }
6071
6072 MenuTextureReload(CommonMenuMes1.tex_block);
6073 CommonMenuMes1.stay_frame = true;
6074 CommonMenuMes1.text_x = 0xDC;
6075 CommonMenuMes1.text_y = 0x8C;
6076 CommonMenuMes1.Step();
6077 CommonMenuMes1.DrawMesWin();
6078 }
6079
6080 if (FishMenu.fade_mode != FISH_EXCHANGE_REFUSE) {
6081 DrawMenuObjectVibe(cursor_x, cursor_y, 1, 0x40);
6082 }
6083}
6084
6085void FishingExchangeDraw() {
6086 int frame_alpha;
6087 int alpha;
6088
6089 setbilinear(0);
6090 frame_alpha = 0x40;
6091 alpha = 0x80;
6092
6093 switch (FishMenu.fade_mode) {
6094 case FISH_EXCHANGE_FADE_IN:
6095 frame_alpha = alpha - FishMenu.fade_count * 2;
6096 alpha = FishMenu.fade_count * 4;
6097 break;
6098 case FISH_EXCHANGE_FADE_OUT:
6099 frame_alpha = FishMenu.fade_count * 2 + 0x40;
6100 alpha = alpha - FishMenu.fade_count * 4;
6101 break;
6102 }
6103
6104 if (frame_alpha > 0x80) {
6105 frame_alpha = 0x80;
6106 }
6107
6108 if (frame_alpha < 0x40) {
6109 frame_alpha = 0x40;
6110 }
6111
6112 if (alpha > 0x80) {
6113 alpha = 0x80;
6114 }
6115
6116 if (alpha < 0) {
6117 alpha = 0;
6118 }
6119
6120 FrameImageDraw(frame_alpha, 0x80);
6121
6122 if (FishMenu.ready != 0) {
6123 FishImageIconDraw(0x50, 0x32, 0xF0, alpha);
6124 FishExchangeItemDraw(0x9C, 0x6A, alpha);
6125 setbilinear(1);
6126 }
6127}
6128
6129void ExitFishingExchange() {
6130 CommonMenuMes1.auto_pos = MES_POS_NONE;
6131 SaveData->SetFishingPoint(FishMenu.point);
6132 TexManager.DeleteTextureBlock(FishMenu.tex_block);
6133 TexManager.CleanUpTextureList();
6134 GamePad.AutoRepeatOff();
6135 GamePad.MenuModeOff();
6136}
6137
6138int FishingExchangeLoop() {
6139 int done;
6140
6141 done = FishingExchangeKey();
6142 FishingExchangeDraw();
6143
6144 if (done) {
6145 ExitFishingExchange();
6146 return 1;
6147 }
6148
6149 return 0;
6150}
6151
6152s8 FishMsg[18] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7};
6153
6154int GetFishMsgNo(int fish_no) {
6155 if (fish_no < 0 || fish_no >= 18) {
6156 return 0;
6157 }
6158
6159 return FishMsg[fish_no] + 30;
6160}
6161
6162SV_FISH_DATA *GetFishingRankData(int rank_index) {
6163 return SaveData->GetFishingRank(rank_index);
6164}
6165
6166void InitFishRecordView(u_long128 *buffer, int *tex_block, int mode) {
6167 u_long128 *load_buffer = buffer;
6168
6169 if (buffer == NULL) {
6170 load_buffer = (u_long128 *) (EdMenuBuffer.base + EdMenuBuffer.used * 16);
6171 }
6172
6173 load_buffer = MenuCalcBufAlignment(load_buffer);
6174 FishRecordMenu.tex_block = tex_block[0];
6175 FishRecordMenu.tex_block2 = tex_block[1];
6176 FishRecordMenu.mode = mode;
6177 StartReadBG();
6178 LoadFileBGMenuData("fishrec.pak", load_buffer);
6179 FishRecordMenu.ready = 0;
6180 FishRecordMenu.cursor = 0;
6181 FishRecordMenu.top = 0;
6182 FishRecordMenu.fade_count = 0;
6183 FishRecordMenu.fade_mode = FISH_RECORD_FADE_IN;
6184 StayTex = TexManager.GetTexture("stayframe", -1);
6185 GamePad.SetAutoRepeat(PAD_DPAD, 0x1E, 5);
6186 GamePad.MenuModeOn(0x78);
6187}
6188
6196static void ExitFishRecord() {
6197 TexManager.DeleteTextureBlock(FishRecordMenu.tex_block);
6198 TexManager.CleanUpTextureList();
6199 GamePad.AutoRepeatOff();
6200 GamePad.MenuModeOff();
6201}
6202
6203void FishRecordTextureEnter() {
6204 if (ReadBGSync() != 0) {
6205 return;
6206 }
6207
6208 BG_READ_INFO *file = GetReadBGFile(0);
6209 LOADTEXTURE_INFO2 texture[3] = {
6210 {FishFrameImage, 0, 0},
6211 {NULL, 0, 0},
6212 {NULL, 0, 0},
6213 };
6214 texture[0].block_no = FishRecordMenu.tex_block;
6215 texture[1].block_no = FishRecordMenu.tex_block;
6216 texture[1].name = (char *) GetPackFile((u_int *) file->buffer, "fishrec.img", NULL);
6217 TexManager.DeleteTextureBlock(FishRecordMenu.tex_block);
6218 TexManager.CleanUpTextureList();
6219 TexManager.LoadTextureBlockEX(-1, texture);
6220 FishMenuTex = TexManager.GetTexture("fprecbrd", -1);
6221 InitMenuMesSet(MENU_MES_SET_ALLMENU, (short *) GetPackFile((u_int *) file->buffer, FishMessageFile, NULL));
6222 CommonMenuMes2.mes_made = -1;
6223 AtoraNameMes.mes_made = -1;
6224
6225 for (int i = 0; i < 5; i++) {
6226 SV_FISH_DATA *rank = GetFishingRankData(FishRecordMenu.top + i);
6227
6228 if (rank != NULL) {
6229 AtoraNameMes.mes_no[i] = GetFishMsgNo(*(int *) rank);
6230 } else {
6231 AtoraNameMes.mes_no[i] = 0;
6232 }
6233 }
6234
6235 AtoraNameMes.MakeMesWin(0xC8);
6236 FishRecordMenu.cursor_y = 0x7E;
6237 FishRecordMenu.ready = 1;
6238}
6239
6247static int FishRecordViewKey() {
6248 ReadBG();
6249 int ret = 0;
6250
6251 switch (FishRecordMenu.fade_mode) {
6252 case FISH_RECORD_FADE_IN:
6253 FishRecordMenu.fade_count++;
6254
6255 if (!FishRecordMenu.ready) {
6256 FishRecordTextureEnter();
6257 } else if (FishRecordMenu.fade_count > 0x20) {
6258 FishRecordMenu.fade_mode = FISH_RECORD_VIEW;
6259 FishRecordMenu.fade_count = 0;
6260 }
6261
6262 break;
6263 case FISH_RECORD_FADE_OUT:
6264 FishRecordMenu.fade_count++;
6265
6266 if (FishRecordMenu.fade_count > 0x20) {
6267 ExitFishRecord();
6268 ret = 1;
6269 }
6270
6271 break;
6272 case FISH_RECORD_VIEW: {
6273 int old_cursor = FishRecordMenu.cursor;
6274
6275 if (GamePad.Down(PAD_R2 | PAD_R1 | PAD_RIGHT)) {
6276 FishRecordMenu.top += 5;
6277 FishRecordMenu.cursor += 5;
6278
6279 if (FishRecordMenu.top > 0x10) {
6280 FishRecordMenu.top = 0xF;
6281 }
6282
6283 if (FishRecordMenu.cursor >= 0x13) {
6284 FishRecordMenu.cursor = 0x13;
6285 }
6286 }
6287
6288 if (GamePad.Down(PAD_L2 | PAD_L1 | PAD_LEFT)) {
6289 FishRecordMenu.top -= 5;
6290 FishRecordMenu.cursor -= 5;
6291
6292 if (FishRecordMenu.cursor < 0 || FishRecordMenu.top < 0) {
6293 FishRecordMenu.cursor = 0;
6294 FishRecordMenu.top = 0;
6295 }
6296 }
6297
6298 if (GamePad.Down(PAD_UP)) {
6299 FishRecordMenu.cursor--;
6300
6301 if (FishRecordMenu.cursor < 0) {
6302 FishRecordMenu.cursor = 0;
6303 }
6304
6305 if (FishRecordMenu.cursor < FishRecordMenu.top) {
6306 FishRecordMenu.top--;
6307 }
6308
6309 if (FishRecordMenu.top < 0) {
6310 FishRecordMenu.top = 0;
6311 FishRecordMenu.cursor = 0;
6312 }
6313 }
6314
6315 if (GamePad.Down(PAD_DOWN)) {
6316 FishRecordMenu.cursor++;
6317
6318 if (FishRecordMenu.cursor >= 0x13) {
6319 FishRecordMenu.cursor = 0x13;
6320 }
6321
6322 if (FishRecordMenu.top < FishRecordMenu.cursor - 4) {
6323 FishRecordMenu.top++;
6324
6325 if (FishRecordMenu.top > 0x10) {
6326 FishRecordMenu.top = 0x10;
6327 }
6328 }
6329 }
6330
6331 if (GamePad.Down(PAD_CIRCLE)) {
6332 FishRecordMenu.fade_mode = FISH_RECORD_FADE_OUT;
6333 FishRecordMenu.fade_count = 0;
6334 }
6335
6336#ifdef PAL
6337 // Debug shortcut: records a random catch.
6338 if (DebugMode && GamePad.Down2(PAD_CROSS)) {
6339 int fish_id = rand() % 18;
6340 SaveData->SetFishingRank(fish_id, rand() % 20);
6341 }
6342
6343#endif
6344 if (old_cursor != FishRecordMenu.cursor) {
6345 ComMenuSePlay(MENU_SOUND_CURSOR);
6346
6347 for (int i = 0; i < 5; i++) {
6348 SV_FISH_DATA *fish = GetFishingRankData(FishRecordMenu.top + i);
6349
6350 if (fish != NULL) {
6351 AtoraNameMes.mes_no[i] = GetFishMsgNo(fish->fish_id);
6352 } else {
6353 AtoraNameMes.mes_no[i] = 0;
6354 }
6355 }
6356
6357 AtoraNameMes.mes_made = -1;
6358 AtoraNameMes.MakeMesWin(0xC8);
6359 }
6360
6361 break;
6362 }
6363 }
6364
6365 return ret;
6366}
6367
6375static void FishRecordViewBoard(int x, int y, int alpha) {
6376 int pos_x;
6377 int pos_y;
6378
6379 MenuTextureReload(FishMenu.tex_block);
6380 DrawMenu2DSprite(FishMenuTex, CRect_i_(x, y, 0x160, 0xD0), CRect_i_(0, 0, 0x160, 0xD0), alpha);
6381 int head_y = y - 0xE;
6382 pos_x = x + 0x10;
6383 CRect_i_ head(0x160, 0x1A, 0x44, 0x1C);
6384 int widths[3] = {0x54, 0x5A, 0};
6385
6386 for (int i = 0; i <= 2; i++, head.y += head.height) {
6387 if (i == 2) {
6388 head.width = 0x74;
6389 }
6390
6391 DrawMenu2DSprite(FishMenuTex, CRect_i_(pos_x, head_y, head.width, head.height - 1), head, alpha);
6392 pos_x += widths[i];
6393 }
6394
6395 int bar_x = x + 0x144;
6396 float length = 23.5f;
6397 int bar_y = (int) ((float) (y + 0x2A) + 6.3f * FishRecordMenu.top);
6398 CRect_i_ source(0x110, 0xD0, 8, 4);
6399 DrawMenu2DSprite(FishMenuTex, CRect_i_(bar_x, bar_y, 8, 4), source, alpha);
6400 source.y += 4;
6401 DrawMenu2DSprite(FishMenuTex, CRect_i_(bar_x, bar_y + 4, 8, (int) length), source, alpha);
6402 source.y += 4;
6403 DrawMenu2DSprite(FishMenuTex, CRect_i_(bar_x, (int) ((float) (bar_y + 4) + length), 8, 4), source, alpha);
6404 pos_x = x + 0x12;
6405 pos_y = y + 6;
6406
6407 for (int i = 0; i < 5; i++, pos_y += 0x22) {
6408 int rank_no = FishRecordMenu.top + i;
6409 SV_FISH_DATA *record = GetFishingRankData(rank_no);
6410 RECT digits = {0x158, 0xDC, 0xE, 0x12};
6411
6412 if (rank_no == FishRecordMenu.cursor) {
6413 digits.y += digits.height;
6414 }
6415
6416 CRect_i_ medal(0x160, 0, 0x20, 0x1B);
6417 int medal_x = pos_x + 0x10;
6418
6419 if (rank_no != 0) {
6420 medal.x += 0x20;
6421
6422 if (rank_no == FishRecordMenu.cursor) {
6423 medal.x += 0x20;
6424 }
6425 }
6426
6427 DrawMenu2DSprite(FishMenuTex, CRect_i_(medal_x, pos_y + 0x14, medal.width, medal.height - 1), medal, alpha);
6428 int number_x = medal_x + 0x14;
6429
6430 if (GetNumberKeta(rank_no + 1) >= 2) {
6431 number_x += digits.width >> 1;
6432 }
6433
6434 DrawMenuNumber(rank_no + 1, number_x, pos_y + 0x18, FishMenuTex, digits, 1, alpha);
6435 int size = 0;
6436
6437 if (record != NULL) {
6438 size = (int) record->rank;
6439 }
6440
6441 if (size > 0) {
6442 DrawMenuNumber(size, pos_x + 0xFE, pos_y + 0x18, FishMenuTex, digits, 1, alpha);
6443 DrawMenu2DSprite(FishMenuTex, CRect_i_(pos_x + 0xFE, pos_y + 0x16, digits.width * 2, digits.height), CRect_i_(digits.x + digits.width * 10, digits.y, digits.width * 2, digits.height), alpha);
6444
6445 if (i >= 0 && i < 10) {
6446 AtoraNameMes.line_pos[i].x = pos_x + 0x3E;
6447 AtoraNameMes.line_pos[i].y = pos_y + 0x14;
6448 }
6449 }
6450 }
6451
6452 if (GetMardanGareyanFlag() != 0) {
6453 pos_x = x + 0x134;
6454 pos_y = y + 0xB6;
6455 DrawMenu2DSprite(FishMenuTex, CRect_i_(pos_x, pos_y, 0x28, 0x28), CRect_i_(0x1D8, 0xB4, 0x28, 0x28), alpha);
6456 }
6457
6458 int row = FishRecordMenu.cursor - FishRecordMenu.top;
6459 pos_y = y + 0x14 + row * 0x22;
6460 pos_x = x + 0x16;
6461 pos_x = (int) (pos_x - 0x1C);
6462 FishRecordMenu.cursor_y += (int) ((float) (pos_y - FishRecordMenu.cursor_y) / 4.0f);
6463
6464 if (abs(FishRecordMenu.cursor_y - pos_y) < 2) {
6465 FishRecordMenu.cursor_y = pos_y;
6466 }
6467
6468 pos_y = FishRecordMenu.cursor_y;
6469 MenuTextureReload(CommonMenuMes2.tex_block);
6470 AtoraNameMes.edge_alpha = alpha;
6471 AtoraNameMes.Step();
6472 AtoraNameMes.DrawMesWin();
6473 DrawMenuObjectVibe(pos_x, pos_y, 1, 0x40);
6474}
6475
6483static void FishRecordViewDraw() {
6484 int frame_alpha;
6485 int alpha;
6486
6487 setbilinear(0);
6488 frame_alpha = 0x40;
6489 alpha = 0x80;
6490
6491 switch (FishRecordMenu.fade_mode) {
6492 case FISH_RECORD_FADE_IN:
6493 frame_alpha = alpha - FishRecordMenu.fade_count * 2;
6494 alpha = FishRecordMenu.fade_count * 4;
6495 break;
6496 case FISH_RECORD_FADE_OUT:
6497 frame_alpha = FishRecordMenu.fade_count * 2 + 0x40;
6498 alpha = alpha - FishRecordMenu.fade_count * 4;
6499 break;
6500 }
6501
6502 if (frame_alpha > 0x80) {
6503 frame_alpha = 0x80;
6504 }
6505
6506 if (frame_alpha < 0x40) {
6507 frame_alpha = 0x40;
6508 }
6509
6510 if (alpha > 0x80) {
6511 alpha = 0x80;
6512 }
6513
6514 if (alpha < 0) {
6515 alpha = 0;
6516 }
6517
6518 FrameImageDraw(frame_alpha, 0x80);
6519
6520 if (FishRecordMenu.ready != 0) {
6521 FishImageIconDraw(0x50, 0x32, 0x10C, alpha);
6522 FishRecordViewBoard(0x9C, 0x6A, alpha);
6523 setbilinear(1);
6524 }
6525}
6526
6527int FishRecordViewLoop() {
6528 int done;
6529
6530 done = FishRecordViewKey();
6531 FishRecordViewDraw();
6532 return done;
6533}
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 GetPos(float *pos)
Definition camera.cpp:230
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 body_height
virtual void Draw()
virtual void SetPosition(float x, float y, float z)
int SearchItemIndexNo(int item_id)
int AllOn()
Definition gamepad.cpp:465
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
void CheckItemVolume()
virtual void GetRotation(float *out_rotation)
Definition object.cpp:116
virtual void GetScale(float *out_scale)
Definition object.cpp:174
float pos[4]
Definition object.hpp:18
void SetFishingRank(int fish_id, float score)
Definition savedata.cpp:129
CDngStatusData * GetDngStatus()
Definition savedata.cpp:250
s32 GetMardanGareyanFlag() const
Definition savedata.hpp:495
int GetGameFlag(int flag_no)
Definition savedata.cpp:258
s32 GetFishingPoint() const
Definition savedata.hpp:492
int SetGameFlag(int flag_no, int value)
Definition savedata.cpp:279
int GetGameIntFlag(int flag_no)
Definition savedata.cpp:310
void SetFishingPoint(int value)
Definition savedata.cpp:117
SV_FISH_DATA * GetFishingRank(int rank_index)
Definition savedata.cpp:163
s32 mardan_garayan_caught
Definition savedata.hpp:144
CStockItem * GetStockItem()
Definition savedata.cpp:254
int SetGameIntFlag(int flag_no, int value)
Definition savedata.cpp:318
ATTACH_LIST attachments[30]
Definition stockitem.hpp:34
void SeitonItem()
int SearchSpace(int slot_index, int search_space)
Definition stockitem.cpp:45
void GetAttachInfo(int slot_index, ATTACH_LIST *attachment)
void SeitonAttach()
void SetAttachToPos(int slot_index, ATTACH_LIST *attachment)
void SetWepToPos(int slot_index, WEAPON_HAVE *weapon)
Definition stockitem.cpp:95
WEAPON_HAVE weapons[30]
Definition stockitem.hpp:33
s16 dungeon_items[60]
Definition stockitem.hpp:31
int GetNowModeSpace(int search_space)
void GetItemInfo(int slot_index, s16 *item_no, s16 *volume)
Definition stockitem.cpp:90
void GetWeaponInfo(int slot_index, WEAPON_HAVE *weapon)
void SetItemToPos(int slot_index, s16 *item_no, s16 *volume)
Definition stockitem.cpp:78
ITEM_PACK item_pack
DNG_CONSUMABLE consumable_items[43]
WEAPON_HAVE chara_weapons[6][11]
s8 equipped_weapon_slot[6]
s32 auto_pos
Definition clsmes.hpp:172
s32 text_y
Definition clsmes.hpp:152
s32 text_x
Definition clsmes.hpp:151
s32 tail_on
Definition clsmes.hpp:173
void DrawMesWin()
Definition clsmes.cpp:2619
void Step()
Definition clsmes.cpp:575
s32 mes_no[10]
Definition clsmes.hpp:216
s32 page_arrow
Definition clsmes.hpp:209
s32 value
Definition clsmes.hpp:218
void AutoSet(int *pos)
Definition clsmes.cpp:173
s32 narrow_gaiji
Definition clsmes.hpp:215
void SetBuff(short *buff)
Definition clsmes.cpp:456
s32 mes_made
Definition clsmes.hpp:207
s32 values[8]
Definition clsmes.hpp:217
s32 style
Definition clsmes.hpp:208
s32 tex_block
Definition clsmes.hpp:227
s32 value_signed
Definition clsmes.hpp:219
s32 stay_frame
Definition clsmes.hpp:189
s32 edge_alpha
Definition clsmes.hpp:213
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
int State()
Definition clsmes.cpp:637
void Preset(int style)
Definition clsmes.cpp:468
s32 rows
Definition clsmes.hpp:156
void IconAutoMoveDraw()
Definition shop.cpp:620
s16 item_no
Definition shop.hpp:201
float pos_x
Definition shop.hpp:199
void IconMoveTarSet(int slot_no, int icon_no, int item_no, MENU_ITEMDATA *item_data, float start_x, float start_y, int to_stock)
Definition shop.cpp:512
int IconAutoMove(int item_shop, int force_arrive)
Definition shop.cpp:522
MENU_ITEMDATA data
Definition shop.hpp:203
s16 to_stock
Definition shop.hpp:195
float pos_y
Definition shop.hpp:200
s16 icon_no
Definition shop.hpp:198
s16 slot_no
Definition shop.hpp:197
@ ITEM_SORT_FOOD
Definition itemdata.hpp:23
@ ITEM_SORT_COUNT
Definition itemdata.hpp:31
@ ITEM_SORT_NONE
Definition itemdata.hpp:22
@ ITEMKINDF_THROWABLE
Definition itemdata.hpp:555
@ INTERPOLATE_STEP
Definition mathutil.hpp:15
s16 sphere_weapon_no
Definition itemdata.hpp:592
u_long128 * buffer
Definition dataread.hpp:29
s16 warning
Definition shop.cpp:111
s32 cursor_y
Definition shop.cpp:113
s16 fade_mode
Definition shop.cpp:117
s16 tex_block2
Definition shop.cpp:109
u_long128 * buffer
Definition shop.cpp:121
s16 confirm
Definition shop.cpp:115
s16 tex_block
Definition shop.cpp:108
s32 fade_count
Definition shop.cpp:120
s16 volume
Definition shop.hpp:152
s32 from_page
Definition shop.hpp:148
s32 slot_state
Definition shop.hpp:147
s32 last_slot
Definition shop.hpp:149
s16 item_no
Definition shop.hpp:151
s32 from_slot
Definition shop.hpp:150
s16 kind_flags
Definition itemdata.hpp:528
Definition shop.cpp:160
s16 sell_price
Definition shop.cpp:162
s16 buy_price
Definition shop.cpp:161
s16 quick_item_slot[3]
s16 quick_item_qty[3]
s16 item_vol[103]
s16 item[103]
WEAPON_HAVE weapon
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
MENU_ITEMDATA data
Definition shop.hpp:138
PERSONAL_BOARD board
Definition shop_menu.hpp:18
s16 stock_row_offset
Definition shop_menu.hpp:22
float stock_scroll
Definition shop_menu.hpp:21
s16 person_tex_block
Definition shop_menu.hpp:37
ATTACH_LIST attach[6]
Definition itemdata.hpp:701
s16 param[0x7C]
Definition shop.hpp:127
ATTACH_LIST attach
Definition shop.hpp:126
WEAPON_HAVE weapon
Definition shop.hpp:125