summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm/slot_machine.s204
-rw-r--r--include/slot_machine.h6
-rw-r--r--src/field/slot_machine.c104
3 files changed, 101 insertions, 213 deletions
diff --git a/asm/slot_machine.s b/asm/slot_machine.s
index a289ec573..9b3926f85 100644
--- a/asm/slot_machine.s
+++ b/asm/slot_machine.s
@@ -5,210 +5,6 @@
.text
- thumb_func_start sub_8101DB0
-sub_8101DB0: @ 8101DB0
- push {lr}
- ldr r2, _08101DD8 @ =gSharedMem
- movs r0, 0
- strh r0, [r2, 0xE]
- strh r0, [r2, 0x12]
- strh r0, [r2, 0x18]
- ldrb r1, [r2, 0x4]
- movs r0, 0xC0
- ands r0, r1
- strb r0, [r2, 0x4]
- movs r0, 0x4
- strb r0, [r2]
- movs r1, 0xC
- ldrsh r0, [r2, r1]
- cmp r0, 0
- bgt _08101DDC
- movs r0, 0x19
- strb r0, [r2]
- b _08101DEC
- .align 2, 0
-_08101DD8: .4byte gSharedMem
-_08101DDC:
- ldrb r0, [r2, 0xA]
- cmp r0, 0
- beq _08101DEC
- movs r0, 0x3
- strb r0, [r2]
- movs r0, 0x4
- bl sub_8104CAC
-_08101DEC:
- movs r0, 0x1
- pop {r1}
- bx r1
- thumb_func_end sub_8101DB0
-
- thumb_func_start sub_8101DF4
-sub_8101DF4: @ 8101DF4
- push {lr}
- bl sub_8104E18
- lsls r0, 24
- cmp r0, 0
- beq _08101E06
- ldr r1, _08101E0C @ =gSharedMem
- movs r0, 0x4
- strb r0, [r1]
-_08101E06:
- movs r0, 0
- pop {r1}
- bx r1
- .align 2, 0
-_08101E0C: .4byte gSharedMem
- thumb_func_end sub_8101DF4
-
- thumb_func_start sub_8101E10
-sub_8101E10: @ 8101E10
- push {lr}
- movs r0, 0
- bl sub_8104CAC
- ldr r2, _08101E34 @ =gSharedMem
- movs r0, 0x5
- strb r0, [r2]
- movs r0, 0xC
- ldrsh r1, [r2, r0]
- ldr r0, _08101E38 @ =0x0000270e
- cmp r1, r0
- ble _08101E2C
- movs r0, 0x17
- strb r0, [r2]
-_08101E2C:
- movs r0, 0x1
- pop {r1}
- bx r1
- .align 2, 0
-_08101E34: .4byte gSharedMem
-_08101E38: .4byte 0x0000270e
- thumb_func_end sub_8101E10
-
- thumb_func_start sub_8101E3C
-sub_8101E3C: @ 8101E3C
- push {r4,lr}
- ldr r0, _08101E58 @ =gMain
- ldrh r1, [r0, 0x2E]
- movs r0, 0x4
- ands r0, r1
- cmp r0, 0
- beq _08101E60
- movs r0, 0
- bl sub_8104AB8
- ldr r1, _08101E5C @ =gSharedMem
- movs r0, 0x8
- strb r0, [r1]
- b _08101F1A
- .align 2, 0
-_08101E58: .4byte gMain
-_08101E5C: .4byte gSharedMem
-_08101E60:
- movs r0, 0x80
- lsls r0, 1
- ands r0, r1
- cmp r0, 0
- beq _08101EC2
- ldr r2, _08101EB8 @ =gSharedMem
- movs r1, 0xC
- ldrsh r0, [r2, r1]
- subs r0, 0x3
- movs r3, 0x12
- ldrsh r1, [r2, r3]
- adds r0, r1
- cmp r0, 0
- blt _08101EBC
- ldrh r4, [r2, 0x12]
- adds r0, r1, 0
- cmp r0, 0x2
- bgt _08101E9C
-_08101E84:
- lsls r0, r4, 24
- lsrs r0, 24
- bl sub_8103D50
- lsls r0, r4, 16
- movs r2, 0x80
- lsls r2, 9
- adds r0, r2
- lsrs r4, r0, 16
- asrs r0, 16
- cmp r0, 0x2
- ble _08101E84
-_08101E9C:
- ldr r1, _08101EB8 @ =gSharedMem
- ldrh r0, [r1, 0xC]
- subs r0, 0x3
- ldrh r3, [r1, 0x12]
- adds r0, r3
- strh r0, [r1, 0xC]
- movs r0, 0x3
- strh r0, [r1, 0x12]
- movs r0, 0x9
- strb r0, [r1]
- movs r0, 0x5F
- bl PlaySE
- b _08101F1A
- .align 2, 0
-_08101EB8: .4byte gSharedMem
-_08101EBC:
- movs r0, 0x6
- strb r0, [r2]
- b _08101F1A
-_08101EC2:
- movs r0, 0x80
- ands r0, r1
- cmp r0, 0
- beq _08101EEC
- ldr r4, _08101F24 @ =gSharedMem
- movs r1, 0xC
- ldrsh r0, [r4, r1]
- cmp r0, 0
- beq _08101EEC
- movs r0, 0x5F
- bl PlaySE
- ldrb r0, [r4, 0x12]
- bl sub_8103D50
- ldrh r0, [r4, 0xC]
- subs r0, 0x1
- strh r0, [r4, 0xC]
- ldrh r0, [r4, 0x12]
- adds r0, 0x1
- strh r0, [r4, 0x12]
-_08101EEC:
- ldr r0, _08101F24 @ =gSharedMem
- movs r2, 0x12
- ldrsh r1, [r0, r2]
- ldr r2, _08101F28 @ =gMain
- adds r3, r0, 0
- cmp r1, 0x2
- bgt _08101F08
- cmp r1, 0
- beq _08101F0C
- ldrh r1, [r2, 0x2E]
- movs r0, 0x1
- ands r0, r1
- cmp r0, 0
- beq _08101F0C
-_08101F08:
- movs r0, 0x9
- strb r0, [r3]
-_08101F0C:
- ldrh r1, [r2, 0x2E]
- movs r0, 0x2
- ands r0, r1
- cmp r0, 0
- beq _08101F1A
- movs r0, 0x15
- strb r0, [r3]
-_08101F1A:
- movs r0, 0
- pop {r4}
- pop {r1}
- bx r1
- .align 2, 0
-_08101F24: .4byte gSharedMem
-_08101F28: .4byte gMain
- thumb_func_end sub_8101E3C
-
thumb_func_start sub_8101F2C
sub_8101F2C: @ 8101F2C
push {r4,lr}
diff --git a/include/slot_machine.h b/include/slot_machine.h
index 60b1f177a..421946103 100644
--- a/include/slot_machine.h
+++ b/include/slot_machine.h
@@ -2,7 +2,7 @@
#define GUARD_SLOT_MACHINE_H
struct SlotMachineEwramStruct {
- /*0x00*/ u8 unk00;
+ /*0x00*/ u8 state;
/*0x01*/ u8 unk01;
/*0x02*/ u8 unk02;
/*0x03*/ u8 unk03;
@@ -11,10 +11,10 @@ struct SlotMachineEwramStruct {
/*0x08*/ u16 unk08;
/*0x0A*/ u8 unk0A;
/*0x0B*/ u8 unk0B;
- /*0x0C*/ u16 coins;
+ /*0x0C*/ s16 coins;
/*0x0E*/ u16 unk0E;
/*0x10*/ u16 unk10;
- /*0x12*/ u16 unk12;
+ /*0x12*/ s16 bet;
/*0x14*/ u8 filler14[4];
/*0x18*/ u16 unk18;
/*0x1A*/ u16 unk1A;
diff --git a/src/field/slot_machine.c b/src/field/slot_machine.c
index cb1326151..16cfea7b5 100644
--- a/src/field/slot_machine.c
+++ b/src/field/slot_machine.c
@@ -1,4 +1,5 @@
#include "global.h"
+#include "constants/songs.h"
#include "random.h"
#include "sound.h"
#include "main.h"
@@ -51,16 +52,20 @@ void sub_8101D04(void);
void sub_8101D24(u8 taskId);
void sub_8102DA8(void);
+void sub_8103D50(u8 a0);
void sub_8103DC8(void);
void sub_8104048(void);
void sub_810423C(u8 a0);
+void sub_8104AB8(u8 a0);
void sub_8104C5C(void);
+void sub_8104CAC(u8 arg0);
+bool8 sub_8104E18(void);
void sub_8104EA8(void);
void sub_8104F8C(void);
void sub_81050C4(void);
+void sub_81063C0(void);
void sub_8106448(void);
void sub_81064B8(void);
-void sub_81063C0(void);
void PlaySlotMachine(u8 arg0, void *ptr)
{
@@ -204,7 +209,7 @@ void sub_8101BA4(void)
u8 i;
sub_81019EC();
- eSlotMachine->unk00 = 0;
+ eSlotMachine->state = 0;
eSlotMachine->unk02 = 0;
eSlotMachine->unk03 = Random() & 1;
eSlotMachine->unk04 = 0;
@@ -214,7 +219,7 @@ void sub_8101BA4(void)
eSlotMachine->coins = gSaveBlock1.coins;
eSlotMachine->unk0E = 0;
eSlotMachine->unk10 = 0;
- eSlotMachine->unk12 = 0;
+ eSlotMachine->bet = 0;
eSlotMachine->unk18 = 0;
eSlotMachine->unk1A = 8;
eSlotMachine->win0h = 0xf0;
@@ -278,14 +283,14 @@ void sub_8101D04(void)
void sub_8101D24(u8 taskId)
{
- while (gUnknown_083ECAAC[eSlotMachine->unk00](gTasks + taskId));
+ while (gUnknown_083ECAAC[eSlotMachine->state](gTasks + taskId));
}
bool8 sub_8101D5C(struct Task *task)
{
BeginNormalPaletteFade(-1, 0, 16, 0, 0);
sub_810423C(eSlotMachine->unk02);
- eSlotMachine->unk00++;
+ eSlotMachine->state++;
return FALSE;
}
@@ -293,7 +298,94 @@ bool8 sub_8101D8C(struct Task *task)
{
if (!gPaletteFade.active)
{
- eSlotMachine->unk00++;
+ eSlotMachine->state++;
+ }
+ return FALSE;
+}
+
+bool8 sub_8101DB0(struct Task *task)
+{
+ eSlotMachine->unk0E = 0;
+ eSlotMachine->bet = 0;
+ eSlotMachine->unk18 = 0;
+ eSlotMachine->unk04 &= 0xc0;
+ eSlotMachine->state = 4;
+ if (eSlotMachine->coins <= 0)
+ {
+ eSlotMachine->state = 25;
+ }
+ else if (eSlotMachine->unk0A)
+ {
+ eSlotMachine->state = 3;
+ sub_8104CAC(4);
+ }
+ return TRUE;
+}
+
+bool8 sub_8101DF4(struct Task *task)
+{
+ if (sub_8104E18())
+ {
+ eSlotMachine->state = 4;
+ }
+ return FALSE;
+}
+
+bool8 sub_8101E10(struct Task *task)
+{
+ sub_8104CAC(0);
+ eSlotMachine->state = 5;
+ if (eSlotMachine->coins >= 9999)
+ {
+ eSlotMachine->state = 23;
+ }
+ return TRUE;
+}
+
+bool8 sub_8101E3C(struct Task *task)
+{
+ s16 i;
+
+ if (gMain.newKeys & SELECT_BUTTON)
+ {
+ sub_8104AB8(0);
+ eSlotMachine->state = 8;
+ }
+ else if (gMain.newKeys & R_BUTTON)
+ {
+ if (eSlotMachine->coins - (3 - eSlotMachine->bet) >= 0)
+ {
+ for (i = eSlotMachine->bet; i < 3; i++)
+ {
+ sub_8103D50(i);
+ }
+ eSlotMachine->coins -= (3 - eSlotMachine->bet);
+ eSlotMachine->bet = 3;
+ eSlotMachine->state = 9;
+ PlaySE(SE_REGI);
+ }
+ else
+ {
+ eSlotMachine->state = 6;
+ }
+ }
+ else
+ {
+ if (gMain.newKeys & DPAD_DOWN && eSlotMachine->coins != 0)
+ {
+ PlaySE(SE_REGI);
+ sub_8103D50(eSlotMachine->bet);
+ eSlotMachine->coins--;
+ eSlotMachine->bet++;
+ }
+ if (eSlotMachine->bet >= 3 || (eSlotMachine->bet != 0 && gMain.newKeys & A_BUTTON))
+ {
+ eSlotMachine->state = 9;
+ }
+ if (gMain.newKeys & B_BUTTON)
+ {
+ eSlotMachine->state = 21;
+ }
}
return FALSE;
}