summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm/tv.s52
-rw-r--r--include/global.h10
-rw-r--r--src/tv.c37
3 files changed, 41 insertions, 58 deletions
diff --git a/asm/tv.s b/asm/tv.s
index 9af66c2da..609ca523b 100644
--- a/asm/tv.s
+++ b/asm/tv.s
@@ -2436,58 +2436,6 @@ _080BF14E:
bx r1
thumb_func_end sub_80BF0B8
- thumb_func_start sub_80BF154
-sub_80BF154: @ 80BF154
- push {r4-r7,lr}
- mov r7, r8
- push {r7}
- adds r6, r1, 0
- lsls r0, 24
- lsrs r0, 24
- mov r8, r0
- movs r7, 0
- movs r5, 0
-_080BF166:
- lsls r4, r5, 1
- adds r0, r6, 0x6
- adds r1, r0, r4
- ldrh r0, [r1]
- cmp r0, 0
- beq _080BF186
- bl ItemId_GetPrice
- lsls r0, 16
- lsrs r0, 16
- adds r1, r6, 0
- adds r1, 0xC
- adds r1, r4
- ldrh r1, [r1]
- muls r0, r1
- adds r7, r0
-_080BF186:
- adds r0, r5, 0x1
- lsls r0, 24
- lsrs r5, r0, 24
- cmp r5, 0x2
- bls _080BF166
- ldrb r0, [r6, 0x2]
- cmp r0, 0x1
- bne _080BF1A0
- asrs r1, r7, 1
- mov r0, r8
- bl sub_80BF088
- b _080BF1A8
-_080BF1A0:
- mov r0, r8
- adds r1, r7, 0
- bl sub_80BF088
-_080BF1A8:
- pop {r3}
- mov r8, r3
- pop {r4-r7}
- pop {r0}
- bx r0
- thumb_func_end sub_80BF154
-
.section .text_80BF544
thumb_func_start sub_80BFF68
diff --git a/include/global.h b/include/global.h
index f8e53f72c..a6ab3eb63 100644
--- a/include/global.h
+++ b/include/global.h
@@ -289,6 +289,15 @@ struct TVShowUnknownTVShowType2 {
/*0x13*/ u8 playerName[8];
};
+struct TVShowSmartShopper {
+ u8 var00;
+ u8 var01;
+ u8 boughtOrSoldFlag;
+ u8 pad03[3];
+ u16 itemIds[3];
+ u16 itemAmounts[3];
+};
+
typedef union TVShow {
struct TVShowCommon common;
struct TVShowFanClubLetter fanclubLetter;
@@ -298,6 +307,7 @@ typedef union TVShow {
struct TVShowMassOutbreak massOutbreak;
struct TVShowUnknownTVShowType unknownTvShowType;
struct TVShowUnknownTVShowType2 unknownTvShowType2;
+ struct TVShowSmartShopper smartshopperShow;
} TVShow;
struct MailStruct
diff --git a/src/tv.c b/src/tv.c
index ab030116c..8fb19499d 100644
--- a/src/tv.c
+++ b/src/tv.c
@@ -15,6 +15,7 @@
#include "strings.h"
#include "link.h"
#include "easy_chat.h"
+#include "item.h"
struct UnkTvStruct
{
@@ -33,7 +34,7 @@ extern u8 *gUnknown_083D1464[3];
struct TVSaleItem {
u16 item_id;
- u16 item_price;
+ u16 item_amount;
};
extern struct TVSaleItem gUnknown_02038724[3];
@@ -455,9 +456,33 @@ void sub_80BEA88(void)
asm(".section .text_b");
+void sub_80BF088(u8 arg0, s32 price);
+
void sub_80BF6D8(void);
void sub_80BF588(TVShow tvShows[]);
+void sub_80BF154(u8 arg0, struct TVShowSmartShopper *arg1)
+{
+ u8 i;
+ s32 price;
+ price = 0;
+ for (i=0; i<3; i++)
+ {
+ if (arg1->itemIds[i])
+ {
+ price += ItemId_GetPrice(arg1->itemIds[i]) * arg1->itemAmounts[i];
+ }
+ }
+ if (arg1->boughtOrSoldFlag == 1)
+ {
+ sub_80BF088(arg0, price >> 1);
+ }
+ else
+ {
+ sub_80BF088(arg0, price);
+ }
+}
+
bool8 sub_80BF1B4(u8 showIdx)
{
TVShow *tvShows;
@@ -481,19 +506,19 @@ bool8 sub_80BF1B4(u8 showIdx)
void sub_80BF20C(void)
{
u8 i, j;
- u16 tmpId, tmpPrice;
+ u16 tmpId, tmpAmount;
for (i=0; i<2; i++)
{
for (j=i+1; j<3; j++)
{
- if (gUnknown_02038724[i].item_price < gUnknown_02038724[j].item_price)
+ if (gUnknown_02038724[i].item_amount < gUnknown_02038724[j].item_amount)
{
tmpId = gUnknown_02038724[i].item_id;
- tmpPrice = gUnknown_02038724[i].item_price;
+ tmpAmount = gUnknown_02038724[i].item_amount;
gUnknown_02038724[i].item_id = gUnknown_02038724[j].item_id;
- gUnknown_02038724[i].item_price = gUnknown_02038724[j].item_price;
+ gUnknown_02038724[i].item_amount = gUnknown_02038724[j].item_amount;
gUnknown_02038724[j].item_id = tmpId;
- gUnknown_02038724[j].item_price = tmpPrice;
+ gUnknown_02038724[j].item_amount = tmpAmount;
}
}
}