From 0e0d1030443ee5c1ffd281eaa89e0b4dccad6ae7 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 11 Aug 2018 18:47:56 +0200 Subject: [PATCH] port more of slot machine --- asm/slot_machine.s | 1304 +------------------------------------------ data/slot_machine.s | 90 +-- include/main_menu.h | 1 + src/slot_machine.c | 485 +++++++++++++++- sym_ewram.txt | 2 +- 5 files changed, 551 insertions(+), 1331 deletions(-) diff --git a/asm/slot_machine.s b/asm/slot_machine.s index 066663c42..21cf4a350 100644 --- a/asm/slot_machine.s +++ b/asm/slot_machine.s @@ -7,1269 +7,9 @@ - thumb_func_start sub_812B094 -sub_812B094: @ 812B094 - push {r4,lr} - bl sub_812D20C - lsls r0, 24 - cmp r0, 0 - bne _0812B0CC - ldr r4, =sSlotMachine - ldr r1, [r4] - movs r0, 0x13 - strb r0, [r1] - ldr r2, [r4] - ldrh r1, [r2, 0x8] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0812B0CC - movs r0, 0x9 - strb r0, [r2] - ldr r0, [r4] - ldrb r0, [r0, 0xA] - cmp r0, 0 - beq _0812B0CC - movs r0, 0x4 - bl sub_8104CAC - ldr r1, [r4] - movs r0, 0x12 - strb r0, [r1] -_0812B0CC: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_812B094 - thumb_func_start sub_812B0D8 -sub_812B0D8: @ 812B0D8 - push {lr} - bl sub_8104E18 - lsls r0, 24 - cmp r0, 0 - beq _0812B0FC - ldr r2, =sSlotMachine - ldr r1, [r2] - movs r0, 0x13 - strb r0, [r1] - ldr r2, [r2] - ldrh r1, [r2, 0x8] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0812B0FC - movs r0, 0x9 - strb r0, [r2] -_0812B0FC: - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_812B0D8 - - thumb_func_start sub_812B108 -sub_812B108: @ 812B108 - push {lr} - movs r0, 0 - bl sub_812CEB8 - movs r0, 0x1 - bl sub_812CEB8 - movs r0, 0x2 - bl sub_812CEB8 - ldr r0, =sSlotMachine - ldr r1, [r0] - movs r0, 0x2 - strb r0, [r1] - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_812B108 - - thumb_func_start sub_812B130 -sub_812B130: @ 812B130 - push {lr} - adds r1, r0, 0 - ldrh r0, [r1, 0xA] - adds r0, 0x1 - strh r0, [r1, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x40 - ble _0812B14E - movs r0, 0 - strh r0, [r1, 0xA] - ldr r0, =sSlotMachine - ldr r1, [r0] - movs r0, 0x13 - strb r0, [r1] -_0812B14E: - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_812B130 - - thumb_func_start sub_812B158 -sub_812B158: @ 812B158 - push {lr} - sub sp, 0xC - movs r0, 0 - movs r1, 0 - bl NewMenuHelpers_DrawDialogueFrame - ldr r2, =gText_QuitTheGame - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - movs r1, 0x1 - movs r3, 0 - bl PrintTextOnWindow - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - movs r2, 0x85 - lsls r2, 2 - movs r3, 0xC0 - lsls r3, 1 - movs r0, 0xE - str r0, [sp] - movs r0, 0xF - str r0, [sp, 0x4] - movs r0, 0x15 - movs r1, 0x7 - bl sub_80323CC - ldr r0, =sSlotMachine - ldr r1, [r0] - movs r0, 0x16 - strb r0, [r1] - movs r0, 0 - add sp, 0xC - pop {r1} - bx r1 - .pool - thumb_func_end sub_812B158 - - thumb_func_start sub_812B1B0 -sub_812B1B0: @ 812B1B0 - push {lr} - bl ProcessMenuInputNoWrap_ - lsls r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - bne _0812B1EC - movs r0, 0 - movs r1, 0x1 - bl sub_8197434 - movs r0, 0 - bl sub_812CEB8 - movs r0, 0x1 - bl sub_812CEB8 - movs r0, 0x2 - bl sub_812CEB8 - ldr r0, =sSlotMachine - ldr r1, [r0] - ldrh r0, [r1, 0x12] - ldrh r2, [r1, 0xC] - adds r0, r2 - strh r0, [r1, 0xC] - movs r0, 0x1B - b _0812B206 - .pool -_0812B1EC: - cmp r1, 0x1 - beq _0812B1F8 - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - bne _0812B208 -_0812B1F8: - movs r0, 0 - movs r1, 0x1 - bl sub_8197434 - ldr r0, =sSlotMachine - ldr r1, [r0] - movs r0, 0x5 -_0812B206: - strb r0, [r1] -_0812B208: - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_812B1B0 - - thumb_func_start sub_812B214 -sub_812B214: @ 812B214 - push {lr} - sub sp, 0xC - movs r0, 0 - movs r1, 0 - bl NewMenuHelpers_DrawDialogueFrame - ldr r2, =gText_YouveGot9999Coins - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - movs r1, 0x1 - movs r3, 0 - bl PrintTextOnWindow - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - ldr r0, =sSlotMachine - ldr r1, [r0] - movs r0, 0x18 - strb r0, [r1] - movs r0, 0 - add sp, 0xC - pop {r1} - bx r1 - .pool - thumb_func_end sub_812B214 - - thumb_func_start sub_812B254 -sub_812B254: @ 812B254 - push {lr} - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _0812B272 - movs r0, 0 - movs r1, 0x1 - bl sub_8197434 - ldr r0, =sSlotMachine - ldr r1, [r0] - movs r0, 0x5 - strb r0, [r1] -_0812B272: - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_812B254 - - thumb_func_start sub_812B280 -sub_812B280: @ 812B280 - push {lr} - sub sp, 0xC - movs r0, 0 - movs r1, 0 - bl NewMenuHelpers_DrawDialogueFrame - ldr r2, =gText_YouveRunOutOfCoins - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - movs r1, 0x1 - movs r3, 0 - bl PrintTextOnWindow - movs r0, 0 - movs r1, 0x3 - bl CopyWindowToVram - ldr r0, =sSlotMachine - ldr r1, [r0] - movs r0, 0x1A - strb r0, [r1] - movs r0, 0 - add sp, 0xC - pop {r1} - bx r1 - .pool - thumb_func_end sub_812B280 - - thumb_func_start sub_812B2C0 -sub_812B2C0: @ 812B2C0 - push {lr} - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _0812B2DE - movs r0, 0 - movs r1, 0x1 - bl sub_8197434 - ldr r0, =sSlotMachine - ldr r1, [r0] - movs r0, 0x1B - strb r0, [r1] -_0812B2DE: - movs r0, 0 - pop {r1} - bx r1 - .pool - thumb_func_end sub_812B2C0 - - thumb_func_start sub_812B2EC -sub_812B2EC: @ 812B2EC - push {r4,lr} - sub sp, 0x4 - ldr r4, =sSlotMachine - ldr r0, [r4] - ldrh r0, [r0, 0xC] - bl SetCoins - bl GetCoins - lsls r0, 16 - lsrs r0, 16 - bl sub_80EDD78 - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, [r4] - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - movs r0, 0 - add sp, 0x4 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_812B2EC - - thumb_func_start sub_812B32C -sub_812B32C: @ 812B32C - push {r4-r6,lr} - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - beq _0812B340 - b _0812B470 -_0812B340: - ldr r6, =sSlotMachine - ldr r0, [r6] - ldr r0, [r0, 0x64] - bl SetMainCallback2 - ldr r4, =gUnknown_0203AAF4 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AAF8 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AAFC - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AB00 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AB04 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AB08 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AB0C - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AB10 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AB14 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AB18 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AB1C - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AB20 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AB24 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AB28 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AAE4 - ldr r0, [r4] - cmp r0, 0 - beq _0812B3E4 - bl Free - str r5, [r4] -_0812B3E4: - ldr r4, =gUnknown_0203AAE8 - ldr r0, [r4] - cmp r0, 0 - beq _0812B3F2 - bl Free - str r5, [r4] -_0812B3F2: - ldr r4, =gUnknown_0203AAEC - ldr r0, [r4] - cmp r0, 0 - beq _0812B400 - bl Free - str r5, [r4] -_0812B400: - ldr r4, =gUnknown_0203AAF0 - ldr r0, [r4] - cmp r0, 0 - beq _0812B40E - bl Free - str r5, [r4] -_0812B40E: - ldr r4, =gUnknown_0203AAC8 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AACC - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AAD0 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AAD4 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AAD8 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AADC - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AAE0 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AB2C - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r4, =gUnknown_0203AB30 - ldr r0, [r4] - bl Free - str r5, [r4] - ldr r0, [r6] - bl Free - str r5, [r6] -_0812B470: - movs r0, 0 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_812B32C - - thumb_func_start sub_8102484 -sub_8102484: @ 812B4EC - push {r4,lr} - ldr r4, =sSlotMachine - ldr r1, [r4] - ldrb r0, [r1, 0xA] - cmp r0, 0 - bne _0812B54A - ldrb r1, [r1, 0x4] - movs r0, 0xC0 - ands r0, r1 - cmp r0, 0 - bne _0812B54A - bl sub_812B5B0 - lsls r0, 24 - cmp r0, 0 - beq _0812B52C - bl sub_812B5EC - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x3 - beq _0812B52C - ldr r2, [r4] - ldr r1, =gUnknown_085A77FE - lsls r0, r3, 1 - adds r0, r1 - ldrb r1, [r0] - ldrb r0, [r2, 0x4] - orrs r0, r1 - strb r0, [r2, 0x4] - cmp r3, 0x1 - bne _0812B54A -_0812B52C: - bl sub_812B634 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x5 - beq _0812B54A - ldr r0, =sSlotMachine - ldr r2, [r0] - ldr r1, =gUnknown_085A7804 - lsls r0, r3, 1 - adds r0, r1 - ldrb r1, [r0] - ldrb r0, [r2, 0x4] - orrs r0, r1 - strb r0, [r2, 0x4] -_0812B54A: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8102484 - - thumb_func_start sub_81024F0 -sub_81024F0: @ 812B55C - push {lr} - ldr r2, =sSlotMachine - ldr r1, [r2] - movs r0, 0 - strb r0, [r1, 0x6] - ldr r2, [r2] - ldrb r0, [r2, 0x4] - cmp r0, 0 - beq _0812B572 - movs r0, 0x1 - strb r0, [r2, 0x6] -_0812B572: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81024F0 - - thumb_func_start sub_812B57C -sub_812B57C: @ 812B57C - push {r4,lr} - lsls r0, 24 - lsrs r1, r0, 24 - movs r2, 0 - movs r3, 0x1 - ldr r4, =gUnknown_085A77F6 -_0812B588: - adds r0, r1, 0 - ands r0, r3 - cmp r0, 0 - beq _0812B59C - adds r0, r2, r4 - ldrb r0, [r0] - b _0812B5AA - .pool -_0812B59C: - lsrs r1, 1 - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x7 - bls _0812B588 - movs r0, 0 -_0812B5AA: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_812B57C - - thumb_func_start sub_812B5B0 -sub_812B5B0: @ 812B5B0 - push {r4,lr} - bl Random - lsls r0, 24 - lsrs r0, 24 - ldr r4, =gUnknown_085A76C0 - ldr r1, =sSlotMachine - ldr r1, [r1] - movs r3, 0x12 - ldrsh r2, [r1, r3] - ldrb r3, [r1, 0x1] - lsls r1, r3, 1 - adds r1, r3 - subs r1, 0x1 - adds r2, r1 - adds r2, r4 - ldrb r1, [r2] - cmp r1, r0 - bhi _0812B5E4 - movs r0, 0 - b _0812B5E6 - .pool -_0812B5E4: - movs r0, 0x1 -_0812B5E6: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_812B5B0 - - thumb_func_start sub_812B5EC -sub_812B5EC: @ 812B5EC - push {r4-r6,lr} - movs r5, 0 - ldr r6, =gUnknown_085A76D2 -_0812B5F2: - bl Random - movs r2, 0xFF - ldr r1, =sSlotMachine - ldr r3, [r1] - lsls r1, r5, 16 - asrs r4, r1, 16 - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 1 - ldrb r3, [r3, 0x1] - adds r1, r3 - adds r1, r6 - ldrb r1, [r1] - ands r2, r0 - cmp r1, r2 - bgt _0812B620 - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - asrs r0, 16 - cmp r0, 0x2 - ble _0812B5F2 -_0812B620: - lsls r0, r5, 24 - lsrs r0, 24 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_812B5EC - - thumb_func_start sub_812B634 -sub_812B634: @ 812B634 - push {r4-r7,lr} - mov r7, r8 - push {r7} - movs r6, 0 - ldr r0, =gUnknown_085A76E4 - mov r8, r0 - movs r7, 0x80 - lsls r7, 17 -_0812B644: - bl Random - movs r5, 0xFF - ands r5, r0 - ldr r0, =sSlotMachine - ldr r4, [r0] - lsls r2, r6, 16 - asrs r1, r2, 16 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 1 - ldrb r3, [r4, 0x1] - adds r0, r3 - add r0, r8 - ldrb r3, [r0] - cmp r1, 0 - bne _0812B680 - ldrb r0, [r4, 0x3] - cmp r0, 0x1 - bne _0812B680 - adds r3, 0xA - asrs r0, r7, 16 - cmp r3, r0 - ble _0812B69E - adds r3, r0, 0 - b _0812B69E - .pool -_0812B680: - asrs r0, r2, 16 - cmp r0, 0x4 - bne _0812B69E - ldr r0, =sSlotMachine - ldr r0, [r0] - ldrb r0, [r0, 0x3] - cmp r0, 0x1 - bne _0812B69E - lsls r0, r3, 16 - ldr r1, =0xfff60000 - adds r0, r1 - lsrs r3, r0, 16 - cmp r0, 0 - bge _0812B69E - movs r3, 0 -_0812B69E: - lsls r0, r3, 16 - asrs r0, 16 - cmp r0, r5 - bgt _0812B6B4 - movs r3, 0x80 - lsls r3, 9 - adds r0, r2, r3 - lsrs r6, r0, 16 - asrs r0, 16 - cmp r0, 0x4 - ble _0812B644 -_0812B6B4: - lsls r0, r6, 24 - lsrs r0, 24 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_812B634 - - thumb_func_start sub_812B6CC -sub_812B6CC: @ 812B6CC - push {lr} - lsls r0, 24 - lsrs r3, r0, 24 - ldr r0, =sSlotMachine - ldr r2, [r0] - ldrb r0, [r2, 0x3] - cmp r0, 0 - beq _0812B6E8 - ldr r0, =gUnknown_085A7768 - b _0812B6EA - .pool -_0812B6E8: - ldr r0, =gUnknown_085A7702 -_0812B6EA: - lsls r1, r3, 4 - adds r1, r3 - ldrb r2, [r2, 0x2] - adds r1, r2 - adds r1, r0 - ldrb r0, [r1] - pop {r1} - bx r1 - .pool - thumb_func_end sub_812B6CC - - thumb_func_start sub_812B700 -sub_812B700: @ 812B700 - push {r4-r6,lr} - ldr r0, =sSlotMachine - ldr r1, [r0] - movs r0, 0 - strb r0, [r1, 0x5] - bl Random - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0 - bl sub_812B6CC - lsls r0, 24 - lsrs r0, 24 - cmp r4, r0 - bcc _0812B754 - movs r6, 0x5 - b _0812B72E - .pool -_0812B728: - subs r0, r5, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 -_0812B72E: - lsls r0, r6, 16 - asrs r5, r0, 16 - cmp r5, 0 - ble _0812B74E - bl Random - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r6, 24 - lsrs r0, 24 - bl sub_812B6CC - lsls r0, 24 - lsrs r0, 24 - cmp r4, r0 - bcs _0812B728 -_0812B74E: - ldr r0, =sSlotMachine - ldr r0, [r0] - strb r6, [r0, 0x5] -_0812B754: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_812B700 - - thumb_func_start sub_812B760 -sub_812B760: @ 812B760 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - bl Random - movs r1, 0xFF - ands r1, r0 - ldr r0, =gUnknown_085A77CE - lsls r4, 1 - adds r4, r0 - ldrh r4, [r4] - cmp r1, r4 - bcc _0812B784 - movs r0, 0 - b _0812B786 - .pool -_0812B784: - movs r0, 0x1 -_0812B786: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_812B760 - - thumb_func_start dp15_jump_random_unknown -dp15_jump_random_unknown: @ 812B78C - push {r4,r5,lr} - movs r4, 0 - ldr r0, =sSlotMachine - ldr r0, [r0] - movs r2, 0x10 - ldrsh r1, [r0, r2] - ldr r0, =0x0000012b - cmp r1, r0 - ble _0812B7AC - movs r4, 0x4 - b _0812B7C2 - .pool -_0812B7AC: - cmp r1, 0xF9 - ble _0812B7B4 - movs r4, 0x3 - b _0812B7C2 -_0812B7B4: - cmp r1, 0xC7 - ble _0812B7BC - movs r4, 0x2 - b _0812B7C2 -_0812B7BC: - cmp r1, 0x95 - ble _0812B7C2 - movs r4, 0x1 -_0812B7C2: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 24 - lsrs r1, r0, 24 - ldr r5, =gUnknown_085A77D8 - lsls r4, 2 - adds r0, r4, r5 - ldrb r0, [r0] - cmp r1, r0 - bcs _0812B7E8 - movs r0, 0x4 - b _0812B822 - .pool -_0812B7E8: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 24 - adds r2, r5, 0x2 - adds r2, r4, r2 - ldr r3, =gUnknown_085A77EC - ldr r1, =sSlotMachine - ldr r1, [r1] - ldrb r1, [r1, 0xB] - lsls r1, 1 - adds r1, r3 - ldrb r1, [r1] - ldrb r2, [r2] - adds r1, r2 - lsls r1, 24 - cmp r0, r1 - bcc _0812B820 - movs r0, 0x8 - b _0812B822 - .pool -_0812B820: - movs r0, 0x2 -_0812B822: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end dp15_jump_random_unknown - - thumb_func_start CheckMatch -CheckMatch: @ 812B828 - push {r4,lr} - ldr r4, =sSlotMachine - ldr r1, [r4] - movs r0, 0 - strh r0, [r1, 0x8] - bl sub_812B85C - ldr r0, [r4] - movs r1, 0x12 - ldrsh r0, [r0, r1] - cmp r0, 0x1 - ble _0812B844 - bl sub_812B8D0 -_0812B844: - ldr r0, [r4] - movs r1, 0x12 - ldrsh r0, [r0, r1] - cmp r0, 0x2 - ble _0812B852 - bl sub_812B9A0 -_0812B852: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end CheckMatch - - thumb_func_start sub_812B85C -sub_812B85C: @ 812B85C - push {r4,r5,lr} - movs r0, 0 - movs r1, 0x2 - bl sub_812BC44 - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - movs r0, 0x1 - movs r1, 0x2 - bl sub_812BC44 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x2 - movs r1, 0x2 - bl sub_812BC44 - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_812BA6C - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x9 - beq _0812B8BC - ldr r0, =sSlotMachine - ldr r2, [r0] - ldr r0, =gUnknown_085A7828 - lsls r1, 1 - adds r0, r1, r0 - ldrh r0, [r0] - ldrh r3, [r2, 0xE] - adds r0, r3 - strh r0, [r2, 0xE] - ldr r0, =gUnknown_085A7816 - adds r1, r0 - ldrh r0, [r2, 0x8] - ldrh r1, [r1] - orrs r0, r1 - strh r0, [r2, 0x8] - movs r0, 0 - bl sub_812CF34 -_0812B8BC: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_812B85C - - thumb_func_start sub_812B8D0 -sub_812B8D0: @ 812B8D0 - push {r4,r5,lr} - movs r0, 0 - movs r1, 0x1 - bl sub_812BC44 - lsls r0, 24 - lsrs r5, r0, 24 - movs r0, 0x1 - movs r1, 0x1 - bl sub_812BC44 - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0x2 - movs r1, 0x1 - bl sub_812BC44 - lsls r0, 24 - lsrs r2, r0, 24 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_812BA6C - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x9 - beq _0812B930 - cmp r1, 0 - bne _0812B90C - movs r1, 0x1 -_0812B90C: - ldr r0, =sSlotMachine - ldr r2, [r0] - ldr r0, =gUnknown_085A7828 - lsls r1, 1 - adds r0, r1, r0 - ldrh r0, [r0] - ldrh r3, [r2, 0xE] - adds r0, r3 - strh r0, [r2, 0xE] - ldr r0, =gUnknown_085A7816 - adds r1, r0 - ldrh r0, [r2, 0x8] - ldrh r1, [r1] - orrs r0, r1 - strh r0, [r2, 0x8] - movs r0, 0x1 - bl sub_812CF34 -_0812B930: - movs r0, 0 - movs r1, 0x3 - bl sub_812BC44 - lsls r0, 24 - lsrs r5, r0, 24 - movs r0, 0x1 - movs r1, 0x3 - bl sub_812BC44 - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0x2 - movs r1, 0x3 - bl sub_812BC44 - lsls r0, 24 - lsrs r2, r0, 24 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_812BA6C - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x9 - beq _0812B98E - cmp r1, 0 - bne _0812B96A - movs r1, 0x1 -_0812B96A: - ldr r0, =sSlotMachine - ldr r2, [r0] - ldr r0, =gUnknown_085A7828 - lsls r1, 1 - adds r0, r1, r0 - ldrh r0, [r0] - ldrh r3, [r2, 0xE] - adds r0, r3 - strh r0, [r2, 0xE] - ldr r0, =gUnknown_085A7816 - adds r1, r0 - ldrh r0, [r2, 0x8] - ldrh r1, [r1] - orrs r0, r1 - strh r0, [r2, 0x8] - movs r0, 0x2 - bl sub_812CF34 -_0812B98E: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_812B8D0 - - thumb_func_start sub_812B9A0 -sub_812B9A0: @ 812B9A0 - push {r4,r5,lr} - movs r0, 0 - movs r1, 0x1 - bl sub_812BC44 - lsls r0, 24 - lsrs r5, r0, 24 - movs r0, 0x1 - movs r1, 0x2 - bl sub_812BC44 - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0x2 - movs r1, 0x3 - bl sub_812BC44 - lsls r0, 24 - lsrs r2, r0, 24 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_812BA6C - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x9 - beq _0812B9FE - cmp r1, 0 - beq _0812B9F8 - ldr r0, =sSlotMachine - ldr r2, [r0] - ldr r0, =gUnknown_085A7828 - lsls r1, 1 - adds r0, r1, r0 - ldrh r0, [r0] - ldrh r3, [r2, 0xE] - adds r0, r3 - strh r0, [r2, 0xE] - ldr r0, =gUnknown_085A7816 - adds r1, r0 - ldrh r0, [r2, 0x8] - ldrh r1, [r1] - orrs r0, r1 - strh r0, [r2, 0x8] -_0812B9F8: - movs r0, 0x3 - bl sub_812CF34 -_0812B9FE: - movs r0, 0 - movs r1, 0x3 - bl sub_812BC44 - lsls r0, 24 - lsrs r5, r0, 24 - movs r0, 0x1 - movs r1, 0x2 - bl sub_812BC44 - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0x2 - movs r1, 0x1 - bl sub_812BC44 - lsls r0, 24 - lsrs r2, r0, 24 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_812BA6C - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x9 - beq _0812BA5A - cmp r1, 0 - beq _0812BA54 - ldr r0, =sSlotMachine - ldr r2, [r0] - ldr r0, =gUnknown_085A7828 - lsls r1, 1 - adds r0, r1, r0 - ldrh r0, [r0] - ldrh r3, [r2, 0xE] - adds r0, r3 - strh r0, [r2, 0xE] - ldr r0, =gUnknown_085A7816 - adds r1, r0 - ldrh r0, [r2, 0x8] - ldrh r1, [r1] - orrs r0, r1 - strh r0, [r2, 0x8] -_0812BA54: - movs r0, 0x4 - bl sub_812CF34 -_0812BA5A: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_812B9A0 - - thumb_func_start sub_812BA6C -sub_812BA6C: @ 812BA6C - push {lr} - lsls r0, 24 - lsrs r3, r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - cmp r3, r1 - bne _0812BA90 - cmp r3, r2 - bne _0812BA90 - ldr r0, =gUnknown_085A780E - adds r0, r3, r0 - ldrb r0, [r0] - b _0812BAB6 - .pool -_0812BA90: - cmp r3, 0 - bne _0812BA9C - cmp r1, 0 - bne _0812BA9C - cmp r2, 0x1 - beq _0812BAA8 -_0812BA9C: - cmp r3, 0x1 - bne _0812BAAC - cmp r1, 0x1 - bne _0812BAAC - cmp r2, 0 - bne _0812BAAC -_0812BAA8: - movs r0, 0x6 - b _0812BAB6 -_0812BAAC: - cmp r3, 0x4 - beq _0812BAB4 - movs r0, 0x9 - b _0812BAB6 -_0812BAB4: - movs r0, 0 -_0812BAB6: - pop {r1} - bx r1 - thumb_func_end sub_812BA6C - - thumb_func_start sub_8102A24 -sub_8102A24: @ 812BABC - push {r4,lr} - ldr r4, =sub_812BAFC - adds r0, r4, 0 - movs r1, 0x4 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - bl _call_via_r4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8102A24 - - thumb_func_start sub_8102A44 -sub_8102A44: @ 812BADC - push {lr} - ldr r0, =sub_812BAFC - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - beq _0812BAF4 - movs r0, 0 - b _0812BAF6 - .pool -_0812BAF4: - movs r0, 0x1 -_0812BAF6: - pop {r1} - bx r1 - thumb_func_end sub_8102A44 - - thumb_func_start sub_812BAFC -sub_812BAFC: @ 812BAFC + thumb_func_start sub_8102A64 +sub_8102A64: @ 812BAFC push {r4,r5,lr} lsls r0, 24 lsrs r0, 24 @@ -1294,7 +34,7 @@ _0812BB0E: pop {r0} bx r0 .pool - thumb_func_end sub_812BAFC + thumb_func_end sub_8102A64 thumb_func_start sub_812BB34 sub_812BB34: @ 812BB34 @@ -1424,7 +164,7 @@ sub_812BC20: @ 812BC20 lsls r0, 24 cmp r0, 0 beq _0812BC3A - ldr r0, =sub_812BAFC + ldr r0, =sub_8102A64 bl FindTaskIdByFunc lsls r0, 24 lsrs r0, 24 @@ -1436,8 +176,8 @@ _0812BC3A: .pool thumb_func_end sub_812BC20 - thumb_func_start sub_812BC44 -sub_812BC44: @ 812BC44 + thumb_func_start GetTagOfReelSymbolOnScreenAtPos +GetTagOfReelSymbolOnScreenAtPos: @ 812BC44 push {r4,lr} lsls r0, 24 lsrs r0, 24 @@ -1477,7 +217,7 @@ _0812BC76: pop {r1} bx r1 .pool - thumb_func_end sub_812BC44 + thumb_func_end GetTagOfReelSymbolOnScreenAtPos thumb_func_start sub_812BC98 sub_812BC98: @ 812BC98 @@ -1510,7 +250,7 @@ _0812BCC2: lsls r1, 16 asrs r1, 16 adds r0, r4, 0 - bl sub_812BC44 + bl GetTagOfReelSymbolOnScreenAtPos lsls r0, 24 lsrs r0, 24 pop {r4-r6} @@ -2086,7 +826,7 @@ sub_812C138: @ 812C138 ldr r4, =sSlotMachine ldr r0, [r4] ldrb r0, [r0, 0x4] - bl sub_812B57C + bl sub_810250C lsls r0, 24 lsrs r3, r0, 24 adds r5, r3, 0 @@ -3896,8 +2636,8 @@ _0812CEA8: .pool thumb_func_end sub_8103D50 - thumb_func_start sub_812CEB8 -sub_812CEB8: @ 812CEB8 + thumb_func_start sub_8103D8C +sub_8103D8C: @ 812CEB8 push {r4-r7,lr} lsls r0, 24 lsrs r1, r0, 24 @@ -3925,7 +2665,7 @@ _0812CEE4: pop {r0} bx r0 .pool - thumb_func_end sub_812CEB8 + thumb_func_end sub_8103D8C thumb_func_start sub_8103DC8 sub_8103DC8: @ 812CEF4 @@ -3958,8 +2698,8 @@ _0812CEFA: .pool thumb_func_end sub_8103DC8 - thumb_func_start sub_812CF34 -sub_812CF34: @ 812CF34 + thumb_func_start sub_8103E04 +sub_8103E04: @ 812CF34 lsls r0, 24 lsrs r0, 24 ldr r1, =sSlotMachine @@ -3984,7 +2724,7 @@ sub_812CF34: @ 812CF34 strh r2, [r0, 0x3C] bx lr .pool - thumb_func_end sub_812CF34 + thumb_func_end sub_8103E04 thumb_func_start sub_812CF6C sub_812CF6C: @ 812CF6C @@ -4337,8 +3077,8 @@ sub_812D1DC: @ 812D1DC .pool thumb_func_end sub_812D1DC - thumb_func_start sub_812D20C -sub_812D20C: @ 812D20C + thumb_func_start sub_81040C8 +sub_81040C8: @ 812D20C ldr r2, =gTasks ldr r0, =sSlotMachine ldr r0, [r0] @@ -4353,7 +3093,7 @@ sub_812D20C: @ 812D20C lsrs r0, 24 bx lr .pool - thumb_func_end sub_812D20C + thumb_func_end sub_81040C8 thumb_func_start sub_812D230 sub_812D230: @ 812D230 @@ -4780,7 +3520,7 @@ sub_812D51C: @ 812D51C bl sub_812E650 bl sub_812E70C bl sub_812E7CC - bl sub_812B700 + bl sub_8102680 bl StopMapMusic movs r0, 0xC4 lsls r0, 1 @@ -5066,7 +3806,7 @@ _0812D7B8: b _0812D7D4 _0812D7C6: ldrh r0, [r4, 0x14] - bl sub_812B760 + bl sub_81026DC lsls r0, 24 cmp r0, 0 beq _0812D7D6 @@ -5246,7 +3986,7 @@ sub_812D920: @ 812D920 cmp r0, 0 bne _0812D948 _0812D938: - bl sub_812D20C + bl sub_81040C8 lsls r0, 24 cmp r0, 0 bne _0812D948 @@ -6306,7 +5046,7 @@ sub_812E154: @ 812E154 lsls r1, 16 asrs r1, 16 adds r0, r4, 0 - bl sub_812BC44 + bl GetTagOfReelSymbolOnScreenAtPos lsls r0, 24 lsrs r0, 24 bl GetSpriteTileStartByTag diff --git a/data/slot_machine.s b/data/slot_machine.s index b704cdb7a..0896d6348 100644 --- a/data/slot_machine.s +++ b/data/slot_machine.s @@ -20,36 +20,36 @@ gUnknown_085A7444:: @ 85A7444 gUnknown_085A744C:: @ 85A744C .byte 3, 1, 2, 0 -gUnknown_085A7450:: @ 85A7450 - .4byte sub_812AB04 - .4byte sub_812AB38 - .4byte sub_812AB60 - .4byte sub_812ABA8 - .4byte sub_812ABC8 - .4byte sub_812ABF8 - .4byte sub_812ACF4 - .4byte sub_812AD34 - .4byte sub_812AD60 - .4byte sub_812AD80 - .4byte sub_812ADF4 - .4byte sub_812AE24 - .4byte sub_812AE4C - .4byte sub_812AE88 - .4byte sub_812AEC4 - .4byte sub_812AFFC - .4byte sub_812B01C - .4byte sub_812B094 - .4byte sub_812B0D8 - .4byte sub_812B108 - .4byte sub_812B130 - .4byte sub_812B158 - .4byte sub_812B1B0 - .4byte sub_812B214 - .4byte sub_812B254 - .4byte sub_812B280 - .4byte sub_812B2C0 - .4byte sub_812B2EC - .4byte sub_812B32C +gUnknown_083ECAAC:: @ 85A7450 + .4byte sub_8101D5C + .4byte sub_8101D8C + .4byte sub_8101DB0 + .4byte sub_8101DF4 + .4byte sub_8101E10 + .4byte sub_8101E3C + .4byte sub_8101F44 + .4byte sub_8101F60 + .4byte sub_8101F88 + .4byte sub_8101FA4 + .4byte sub_8102008 + .4byte sub_8102034 + .4byte sub_8102058 + .4byte sub_8102090 + .4byte sub_81020C8 + .4byte sub_81021E0 + .4byte sub_81021FC + .4byte sub_8102264 + .4byte sub_81022A0 + .4byte sub_81022CC + .4byte sub_81022F0 + .4byte sub_8102318 + .4byte sub_8102344 + .4byte sub_810239C + .4byte sub_81023B8 + .4byte sub_81023E0_ + .4byte sub_81023FC + .4byte sub_8102424 + .4byte sub_8102460 gUnknown_085A74C4:: @ 85A74C4 .4byte sub_812BB34 @@ -203,10 +203,10 @@ gUnknown_085A766E:: @ 85A766E gUnknown_085A76AD:: @ 85A76AD .byte 1, 0, 5, 4, 3, 2, 0 -gUnknown_085A76B4:: @ 85A76B4 +gUnknown_083ECCF8:: @ 85A76B4 .2byte 0, 6, 0, 10, 0, 2 -gUnknown_085A76C0:: @ 85A76C0 +gUnknown_083ECD04:: @ 85A76C0 .byte 1, 1, 12 .byte 1, 1, 14 .byte 2, 2, 14 @@ -214,19 +214,19 @@ gUnknown_085A76C0:: @ 85A76C0 .byte 2, 3, 16 .byte 3, 3, 16 -gUnknown_085A76D2:: @ 85A76D2 +gUnknown_083ECD16:: @ 85A76D2 .byte 0x19, 0x19, 0x1E, 0x28, 0x28, 0x32 .byte 0x19, 0x19, 0x1E, 0x1E, 0x23, 0x23 .byte 0x19, 0x19, 0x1E, 0x19, 0x19, 0x1E -gUnknown_085A76E4:: @ 85A76E4 +gUnknown_083ECD28:: @ 85A76E4 .byte 0x14, 0x19, 0x19, 0x14, 0x19, 0x19 .byte 0xC, 0xF, 0xF, 0x12, 0x13, 0x16 .byte 0x19, 0x19, 0x19, 0x1E, 0x1E, 0x28 .byte 0x19, 0x19, 0x14, 0x14, 0xF, 0xF .byte 0x28, 0x28, 0x23, 0x23, 0x28, 0x28 -gUnknown_085A7702:: @ 85A7702 +gUnknown_083ECD46:: @ 85A7702 .byte 0xF3, 0xF3, 0xF3, 0x50, 0x50, 0x50, 0x50, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x5, 0x5, 0x5, 0x5 .byte 0x5, 0x5, 0x5, 0x96, 0x96, 0x96, 0x96, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x64, 0x64, 0x64, 0x5 .byte 0x4, 0x4, 0x4, 0x14, 0x14, 0x14, 0x14, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x64, 0x64, 0x64, 0x28 @@ -234,7 +234,7 @@ gUnknown_085A7702:: @ 85A7702 .byte 0x1, 0x1, 0x1, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x5, 0x5, 0x5, 0x64 .byte 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x6 -gUnknown_085A7768:: @ 85A7768 +gUnknown_083ECDAC:: @ 85A7768 .byte 0xF3, 0xF3, 0xF3, 0xC8, 0xC8, 0xC8, 0xC8, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0x46, 0x46, 0x46, 0x05 .byte 0x05, 0x05, 0x05, 0x19, 0x19, 0x19, 0x19, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x02, 0x02, 0x02, 0x06 .byte 0x04, 0x04, 0x04, 0x19, 0x19, 0x19, 0x19, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x28, 0x28, 0x28, 0x23 @@ -242,45 +242,45 @@ gUnknown_085A7768:: @ 85A7768 .byte 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x28, 0x28, 0x28, 0x64 .byte 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x04, 0x04, 0x3C -gUnknown_085A77CE:: @ 85A77CE +gUnknown_083ECE12:: @ 85A77CE .2byte 0x80, 0xAF, 0xC8, 0xE1, 0x100 -gUnknown_085A77D8:: @ 85A77D8 +gUnknown_083ECE1C:: @ 85A77D8 .byte 10, 0, 5, 0 .byte 10, 0, 10, 0 .byte 10, 0, 15, 0 .byte 10, 0, 25, 0 .byte 10, 0, 35, 0 -gUnknown_085A77EC:: @ 85A77EC +gUnknown_083ECE30:: @ 85A77EC .byte 0, 0 .byte 5, 0 .byte 10, 0 .byte 15, 0 .byte 20, 0 -gUnknown_085A77F6:: @ 85A77F6 +gUnknown_083ECE3A:: @ 85A77F6 .byte 6, 4, 3, 2, 5, 0, 0, 0 -gUnknown_085A77FE:: @ 85A77FE +gUnknown_083ECE42:: @ 85A77FE .byte 0x80, 0 .byte 0x20, 0 .byte 0x40, 0 -gUnknown_085A7804:: @ 85A7804 +gUnknown_083ECE48:: @ 85A7804 .byte 16, 0 .byte 8, 0 .byte 4, 0 .byte 2, 0 .byte 1, 0 -gUnknown_085A780E:: @ 85A780E +sSym2Match:: @ 85A780E .byte 7, 8, 4, 3, 0, 5, 2, 0 -gUnknown_085A7816:: @ 85A7816 +sSlotMatchFlags:: @ 85A7816 .2byte 1, 2, 4, 8, 16, 32, 64, 128, 256 -gUnknown_085A7828:: @ 85A7828 +sSlotPayouts:: @ 85A7828 .2byte 2, 4, 0, 6, 12, 3, 0x5A, 0x12C, 0x12C gUnknown_085A783A:: @ 85A783A diff --git a/include/main_menu.h b/include/main_menu.h index 08cd913dc..4f75b1767 100644 --- a/include/main_menu.h +++ b/include/main_menu.h @@ -2,5 +2,6 @@ #define GUARD_MAIN_MENU_H void CB2_InitMainMenu(void); +void sub_80323CC(u8 a, u8 b, u16 c, u16 d, u8 e, u8 f); #endif // GUARD_MAIN_MENU_H diff --git a/src/slot_machine.c b/src/slot_machine.c index 02e842ce9..fd4726879 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -21,7 +21,7 @@ #include "tv.h" #include "text_window.h" #include "constants/rgb.h" -#include "menu.h" +#include "main_menu.h" enum { @@ -155,13 +155,13 @@ bool8 sub_81020C8(struct Task *task); /*static*/bool8 sub_8102344(struct Task *task); /*static*/bool8 sub_810239C(struct Task *task); /*static*/bool8 sub_81023B8(struct Task *task); -/*static*/bool8 sub_81023E0(struct Task *task); +/*static*/bool8 sub_81023E0_(struct Task *task); /*static*/bool8 sub_81023FC(struct Task *task); /*static*/bool8 sub_8102424(struct Task *task); /*static*/bool8 sub_8102460(struct Task *task); /*static*/void sub_8102484(void); /*static*/void sub_81024F0(void); -/*static*/bool8 sub_8102540(void); +/*static*/bool8 sub_8102540_(void); /*static*/u8 sub_8102578(void); /*static*/u16 dp15_jump_random_unknown(void); /*static*/u8 sub_81025BC(void); @@ -539,9 +539,33 @@ void SlotMachineSetup_3_0(void) ResetTasks(); } +extern u16 *gUnknown_0203AAC8; extern u16 *gUnknown_0203AACC; extern u16 *gUnknown_0203AAD0; extern u16 *gUnknown_0203AADC; +extern void *gUnknown_0203AAF4; +extern void *gUnknown_0203AAF8; +extern void *gUnknown_0203AAFC; +extern void *gUnknown_0203AB00; +extern void *gUnknown_0203AB04; +extern void *gUnknown_0203AB08; +extern void *gUnknown_0203AB0C; +extern void *gUnknown_0203AB10; +extern void *gUnknown_0203AB14; +extern void *gUnknown_0203AB18; +extern void *gUnknown_0203AB1C; +extern void *gUnknown_0203AB20; +extern void *gUnknown_0203AB24; +extern void *gUnknown_0203AB28; +extern void *gUnknown_0203AAE4; +extern void *gUnknown_0203AAE8; +extern void *gUnknown_0203AAEC; +extern void *gUnknown_0203AAF0; +extern void *gUnknown_0203AAD4; +extern void *gUnknown_0203AAD8; +extern void *gUnknown_0203AAE0; +extern void *gUnknown_0203AB2C; +extern void *gUnknown_0203AB30; void SlotMachineSetup_4_0(void) { @@ -694,6 +718,9 @@ bool8 sub_8101E3C(struct Task *task) } extern const u8 gText_YouDontHaveThreeCoins[]; +extern const u8 gText_QuitTheGame[]; +extern const u8 gText_YouveGot9999Coins[]; +extern const u8 gText_YouveRunOutOfCoins[]; bool8 sub_8101F44(struct Task *task) { @@ -885,3 +912,455 @@ bool8 sub_81021FC(struct Task *task) } return FALSE; } + +bool8 sub_8102264(struct Task *task) +{ + if (!sub_81040C8()) + { + sSlotMachine->state = 19; + if (sSlotMachine->matchedSymbols & (1 << SLOT_MACHINE_MATCHED_REPLAY)) + { + sSlotMachine->state = 9; + if (sSlotMachine->unk0A) + { + sub_8104CAC(4); + sSlotMachine->state = 18; + } + } + } + return FALSE; +} + +bool8 sub_81022A0(struct Task *task) +{ + if (sub_8104E18()) + { + sSlotMachine->state = 19; + if (sSlotMachine->matchedSymbols & (1 << SLOT_MACHINE_MATCHED_REPLAY)) + { + sSlotMachine->state = 9; + } + } + return FALSE; +} + +bool8 sub_81022CC(struct Task *task) +{ + sub_8103D8C(0); + sub_8103D8C(1); + sub_8103D8C(2); + sSlotMachine->state = 2; + return FALSE; +} + +bool8 sub_81022F0(struct Task *task) +{ + if (++task->data[1] > 64) + { + task->data[1] = 0; + sSlotMachine->state = 19; + } + return FALSE; +} + +bool8 sub_8102318(struct Task *task) +{ + NewMenuHelpers_DrawDialogueFrame(0, 0); + PrintTextOnWindow(0, 1, gText_QuitTheGame, 0, 1, 0, 0); + CopyWindowToVram(0, 3); + sub_80323CC(0x15, 7, 0x214, 0x180, 0xE, 0xF); + sSlotMachine->state = 22; + return FALSE; +} + +bool8 sub_8102344(struct Task *task) +{ + s8 input = ProcessMenuInputNoWrap_(); + if (input == 0) + { + sub_8197434(0, TRUE); + sub_8103D8C(0); + sub_8103D8C(1); + sub_8103D8C(2); + sSlotMachine->coins += sSlotMachine->bet; + sSlotMachine->state = 27; + } + else if (input == 1 || input == -1) + { + sub_8197434(0, TRUE); + sSlotMachine->state = 5; + } + return FALSE; +} + +bool8 sub_810239C(struct Task *task) +{ + NewMenuHelpers_DrawDialogueFrame(0, 0); + PrintTextOnWindow(0, 1, gText_YouveGot9999Coins, 0, 1, 0, 0); + CopyWindowToVram(0, 3); + sSlotMachine->state = 24; + return FALSE; +} + +bool8 sub_81023B8(struct Task *task) +{ + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + sub_8197434(0, TRUE); + sSlotMachine->state = 5; + } + return FALSE; +} + +bool8 sub_81023E0_(struct Task *task) +{ + NewMenuHelpers_DrawDialogueFrame(0, 0); + PrintTextOnWindow(0, 1, gText_YouveRunOutOfCoins, 0, 1, 0, 0); + CopyWindowToVram(0, 3); + sSlotMachine->state = 26; + return FALSE; +} + +bool8 sub_81023FC(struct Task *task) +{ + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + sub_8197434(0, TRUE); + sSlotMachine->state = 27; + } + return FALSE; +} + +bool8 sub_8102424(struct Task *task) +{ + SetCoins(sSlotMachine->coins); + sub_80EDD78(GetCoins()); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); + sSlotMachine->state++; + return FALSE; +} + +bool8 sub_8102460(struct Task *task) +{ + if (!gPaletteFade.active) + { + SetMainCallback2(sSlotMachine->prevMainCb); + FREE_AND_SET_NULL(gUnknown_0203AAF4); + FREE_AND_SET_NULL(gUnknown_0203AAF8); + FREE_AND_SET_NULL(gUnknown_0203AAFC); + FREE_AND_SET_NULL(gUnknown_0203AB00); + FREE_AND_SET_NULL(gUnknown_0203AB04); + FREE_AND_SET_NULL(gUnknown_0203AB08); + FREE_AND_SET_NULL(gUnknown_0203AB0C); + FREE_AND_SET_NULL(gUnknown_0203AB10); + FREE_AND_SET_NULL(gUnknown_0203AB14); + FREE_AND_SET_NULL(gUnknown_0203AB18); + FREE_AND_SET_NULL(gUnknown_0203AB1C); + FREE_AND_SET_NULL(gUnknown_0203AB20); + FREE_AND_SET_NULL(gUnknown_0203AB24); + FREE_AND_SET_NULL(gUnknown_0203AB28); + if (gUnknown_0203AAE4 != NULL) + FREE_AND_SET_NULL(gUnknown_0203AAE4); + if (gUnknown_0203AAE8 != NULL) + FREE_AND_SET_NULL(gUnknown_0203AAE8); + if (gUnknown_0203AAEC != NULL) + FREE_AND_SET_NULL(gUnknown_0203AAEC); + if (gUnknown_0203AAF0 != NULL) + FREE_AND_SET_NULL(gUnknown_0203AAF0); + FREE_AND_SET_NULL(gUnknown_0203AAC8); + FREE_AND_SET_NULL(gUnknown_0203AACC); + FREE_AND_SET_NULL(gUnknown_0203AAD0); + FREE_AND_SET_NULL(gUnknown_0203AAD4); + FREE_AND_SET_NULL(gUnknown_0203AAD8); + FREE_AND_SET_NULL(gUnknown_0203AADC); + FREE_AND_SET_NULL(gUnknown_0203AAE0); + FREE_AND_SET_NULL(gUnknown_0203AB2C); + FREE_AND_SET_NULL(gUnknown_0203AB30); + + FREE_AND_SET_NULL(sSlotMachine); + } + return FALSE; +} + +void sub_8102484(void) +{ + u8 r3; + + if (sSlotMachine->unk0A == 0) + { + if (!(sSlotMachine->unk04 & 0xc0)) + { + if (sub_8102540_()) + { + r3 = sub_8102578(); + if (r3 != 3) + { + sSlotMachine->unk04 |= gUnknown_083ECE42[r3]; + if (r3 != 1) + { + return; + } + } + } + r3 = sub_81025BC(); + if (r3 != 5) + { + sSlotMachine->unk04 |= gUnknown_083ECE48[r3]; + } + } + } +} + +void sub_81024F0(void) +{ + sSlotMachine->unk06 = 0; + if (sSlotMachine->unk04) + sSlotMachine->unk06 = 1; +} + +u8 sub_810250C(u8 a0) +{ + u8 i; + + for (i = 0; i < 8; i++) + { + if (a0 & 1) + return gUnknown_083ECE3A[i]; + a0 >>= 1; + } + return 0; +} + +bool8 sub_8102540_(void) +{ + u8 rval = Random(); + if (gUnknown_083ECD04[sSlotMachine->unk01][sSlotMachine->bet - 1] > rval) + return TRUE; + return FALSE; +} + +extern const u8 gUnknown_083ECD16[][6]; +extern const u8 gUnknown_083ECD28[][6]; +extern const u8 gUnknown_083ECD46[][17]; +extern const u8 gUnknown_083ECDAC[][17]; + +u8 sub_8102578(void) +{ + s16 i; + + for (i = 0; i < 3; i++) + { + s16 rval = Random() & 0xff; + s16 value = gUnknown_083ECD16[i][sSlotMachine->unk01]; + if (value > rval) + break; + } + return i; +} + +u8 sub_81025BC(void) +{ + s16 i; + + for (i = 0; i < 5; i++) + { + s16 rval = Random() & 0xff; + s16 r3 = gUnknown_083ECD28[i][sSlotMachine->unk01]; + if (i == 0 && sSlotMachine->unk03 == 1) + { + r3 += 10; + if (r3 > 0x100) + r3 = 0x100; + } + else if (i == 4 && sSlotMachine->unk03 == 1) + { + r3 -= 10; + if (r3 < 0) + r3 = 0; + } + if (r3 > rval) + break; + } + return i; +} + +u8 sub_810264C(u8 a0) +{ + if (sSlotMachine->unk03 == 0) + return gUnknown_083ECD46[a0][sSlotMachine->pikaPower]; + else + return gUnknown_083ECDAC[a0][sSlotMachine->pikaPower]; +} + +void sub_8102680(void) +{ + u8 rval; + s16 i; + + sSlotMachine->unk05 = 0; + rval = Random(); + if (rval < sub_810264C(0)) + return; + for (i = 5; i > 0; i--) + { + rval = Random(); + if (rval < sub_810264C(i)) + break; + } + sSlotMachine->unk05 = i; +} + +extern const u16 gUnknown_083ECE12[]; +extern const u16 gUnknown_083ECE1C[][2]; +extern const u16 gUnknown_083ECE30[]; +extern const u16 sSlotMatchFlags[]; +extern const u16 sSlotPayouts[]; + +bool8 sub_81026DC(u16 a0) +{ + u16 rval = Random() & 0xff; + if (rval < gUnknown_083ECE12[a0]) + return TRUE; + else + return FALSE; +} + +u16 dp15_jump_random_unknown(void) +{ + u8 r4 = 0; + u8 rval; + u8 value; + if (sSlotMachine->unk10 >= 300) + r4 = 4; + else if (sSlotMachine->unk10 >= 250) + r4 = 3; + else if (sSlotMachine->unk10 >= 200) + r4 = 2; + else if (sSlotMachine->unk10 >= 150) + r4 = 1; + rval = Random() % 100; + value = gUnknown_083ECE1C[r4][0]; + if (rval < value) + return 4; + rval = Random() % 100; + value = gUnknown_083ECE1C[r4][1] + gUnknown_083ECE30[sSlotMachine->unk0B]; + if (rval < value) + return 2; + return 8; +} + +void CheckMatch(void) +{ + sSlotMachine->matchedSymbols = 0; + CheckMatch_CenterRow(); + if (sSlotMachine->bet > 1) + CheckMatch_TopAndBottom(); + if (sSlotMachine->bet > 2) + CheckMatch_Diagonals(); +} + +void CheckMatch_CenterRow(void) +{ + u8 c1, c2, c3, match; + + c1 = GetTagOfReelSymbolOnScreenAtPos(0, 2); + c2 = GetTagOfReelSymbolOnScreenAtPos(1, 2); + c3 = GetTagOfReelSymbolOnScreenAtPos(2, 2); + match = GetMatchFromSymbolsInRow(c1, c2, c3); + if (match != SLOT_MACHINE_MATCHED_NONE) + { + sSlotMachine->payout += sSlotPayouts[match]; + sSlotMachine->matchedSymbols |= sSlotMatchFlags[match]; + sub_8103E04(0); + } +} + +void CheckMatch_TopAndBottom(void) +{ + u8 c1, c2, c3, match; + + c1 = GetTagOfReelSymbolOnScreenAtPos(0, 1); + c2 = GetTagOfReelSymbolOnScreenAtPos(1, 1); + c3 = GetTagOfReelSymbolOnScreenAtPos(2, 1); + match = GetMatchFromSymbolsInRow(c1, c2, c3); + if (match != SLOT_MACHINE_MATCHED_NONE) + { + if (match == SLOT_MACHINE_MATCHED_1CHERRY) + match = SLOT_MACHINE_MATCHED_2CHERRY; + sSlotMachine->payout += sSlotPayouts[match]; + sSlotMachine->matchedSymbols |= sSlotMatchFlags[match]; + sub_8103E04(1); + } + c1 = GetTagOfReelSymbolOnScreenAtPos(0, 3); + c2 = GetTagOfReelSymbolOnScreenAtPos(1, 3); + c3 = GetTagOfReelSymbolOnScreenAtPos(2, 3); + match = GetMatchFromSymbolsInRow(c1, c2, c3); + if (match != SLOT_MACHINE_MATCHED_NONE) + { + if (match == SLOT_MACHINE_MATCHED_1CHERRY) + match = SLOT_MACHINE_MATCHED_2CHERRY; + sSlotMachine->payout += sSlotPayouts[match]; + sSlotMachine->matchedSymbols |= sSlotMatchFlags[match]; + sub_8103E04(2); + } +} + +void CheckMatch_Diagonals(void) +{ + u8 c1, c2, c3, match; + + c1 = GetTagOfReelSymbolOnScreenAtPos(0, 1); + c2 = GetTagOfReelSymbolOnScreenAtPos(1, 2); + c3 = GetTagOfReelSymbolOnScreenAtPos(2, 3); + match = GetMatchFromSymbolsInRow(c1, c2, c3); + if (match != SLOT_MACHINE_MATCHED_NONE) + { + if (match != SLOT_MACHINE_MATCHED_1CHERRY) + { + sSlotMachine->payout += sSlotPayouts[match]; + sSlotMachine->matchedSymbols |= sSlotMatchFlags[match]; + } + sub_8103E04(3); + } + c1 = GetTagOfReelSymbolOnScreenAtPos(0, 3); + c2 = GetTagOfReelSymbolOnScreenAtPos(1, 2); + c3 = GetTagOfReelSymbolOnScreenAtPos(2, 1); + match = GetMatchFromSymbolsInRow(c1, c2, c3); + if (match != SLOT_MACHINE_MATCHED_NONE) + { + if (match != SLOT_MACHINE_MATCHED_1CHERRY) + { + sSlotMachine->payout += sSlotPayouts[match]; + sSlotMachine->matchedSymbols |= sSlotMatchFlags[match]; + } + sub_8103E04(4); + } +} + +extern const u8 sSym2Match[]; + +u8 GetMatchFromSymbolsInRow(u8 c1, u8 c2, u8 c3) +{ + if (c1 == c2 && c1 == c3) + return sSym2Match[c1]; + if (c1 == SLOT_MACHINE_TAG_7_RED && c2 == SLOT_MACHINE_TAG_7_RED && c3 == SLOT_MACHINE_TAG_7_BLUE) + return SLOT_MACHINE_MATCHED_777_MIXED; + if (c1 == SLOT_MACHINE_TAG_7_BLUE && c2 == SLOT_MACHINE_TAG_7_BLUE && c3 == SLOT_MACHINE_TAG_7_RED) + return SLOT_MACHINE_MATCHED_777_MIXED; + if (c1 == SLOT_MACHINE_TAG_CHERRY) + return SLOT_MACHINE_MATCHED_1CHERRY; + return SLOT_MACHINE_MATCHED_NONE; +} + +void sub_8102A24(void) +{ + sub_8102A64(CreateTask(sub_8102A64, 4)); +} + +bool8 sub_8102A44(void) +{ + if (FindTaskIdByFunc(sub_8102A64) == 0xff) + return TRUE; + else + return FALSE; +} diff --git a/sym_ewram.txt b/sym_ewram.txt index 9a08597a8..4cf633c86 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -593,7 +593,7 @@ gUnknown_0203AB2C: @ 203AB2C gUnknown_0203AB30: @ 203AB30 .space 0x4 -gUnknown_0203AB34: @ 203AB34 +sSlotMachine: @ 203AB34 .space 0x4 .include "src/battle_ai_script_commands.o"