diff options
-rw-r--r-- | asm/slot_machine.s | 119 | ||||
-rw-r--r-- | data/slot_machine.s | 47 | ||||
-rw-r--r-- | src/slot_machine.c | 90 | ||||
-rw-r--r-- | sym_ewram.txt | 3 |
4 files changed, 91 insertions, 168 deletions
diff --git a/asm/slot_machine.s b/asm/slot_machine.s index 0e3a7d8a7..9229072da 100644 --- a/asm/slot_machine.s +++ b/asm/slot_machine.s @@ -5,125 +5,6 @@ .text - thumb_func_start sub_8140BDC -sub_8140BDC: @ 8140BDC - ldr r0, _08140BE8 @ =sSlotMachineState - ldr r0, [r0] - adds r0, 0x50 - ldrh r0, [r0] - bx lr - .align 2, 0 -_08140BE8: .4byte sSlotMachineState - thumb_func_end sub_8140BDC - - thumb_func_start sub_8140BEC -sub_8140BEC: @ 8140BEC - ldr r0, _08140BF4 @ =sSlotMachineState - ldr r0, [r0] - ldrb r0, [r0, 0xE] - bx lr - .align 2, 0 -_08140BF4: .4byte sSlotMachineState - thumb_func_end sub_8140BEC - - thumb_func_start sub_8140BF8 -sub_8140BF8: @ 8140BF8 - ldr r1, _08140C08 @ =sSlotMachineState - ldr r1, [r1] - lsls r0, 2 - adds r1, 0x3C - adds r1, r0 - ldr r0, [r1] - bx lr - .align 2, 0 -_08140C08: .4byte sSlotMachineState - thumb_func_end sub_8140BF8 - - thumb_func_start sub_8140C0C -sub_8140C0C: @ 8140C0C - push {r4,r5,lr} - movs r5, 0 - ldr r4, _08140C3C @ =gUnknown_84655B0 -_08140C12: - adds r0, r4, 0 - bl LoadCompressedObjectPic - adds r4, 0x8 - adds r5, 0x1 - cmp r5, 0x2 - bls _08140C12 - ldr r0, _08140C40 @ =gUnknown_84655C8 - bl LoadSpritePalettes - ldr r4, _08140C44 @ =gUnknown_203F3A4 - movs r0, 0x74 - bl Alloc - str r0, [r4] - cmp r0, 0 - beq _08140C48 - bl sub_8140C6C - movs r0, 0x1 - b _08140C4A - .align 2, 0 -_08140C3C: .4byte gUnknown_84655B0 -_08140C40: .4byte gUnknown_84655C8 -_08140C44: .4byte gUnknown_203F3A4 -_08140C48: - movs r0, 0 -_08140C4A: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8140C0C - - thumb_func_start sub_8140C50 -sub_8140C50: @ 8140C50 - push {r4,lr} - ldr r4, _08140C68 @ =gUnknown_203F3A4 - ldr r0, [r4] - cmp r0, 0 - beq _08140C62 - bl Free - movs r0, 0 - str r0, [r4] -_08140C62: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08140C68: .4byte gUnknown_203F3A4 - thumb_func_end sub_8140C50 - - thumb_func_start sub_8140C6C -sub_8140C6C: @ 8140C6C - push {r4-r6,lr} - adds r4, r0, 0 - movs r2, 0 - movs r5, 0 - adds r6, r4, 0 - adds r6, 0xC -_08140C78: - lsls r0, r2, 2 - adds r1, r4, r0 - str r5, [r1] - adds r3, r2, 0x1 - adds r0, r2 - lsls r0, 2 - movs r1, 0x4 - adds r0, r6 - adds r0, 0x10 -_08140C8A: - str r5, [r0] - subs r0, 0x4 - subs r1, 0x1 - cmp r1, 0 - bge _08140C8A - adds r2, r3, 0 - cmp r2, 0x2 - ble _08140C78 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8140C6C - thumb_func_start sub_8140CA0 sub_8140CA0: @ 8140CA0 push {r4-r7,lr} diff --git a/data/slot_machine.s b/data/slot_machine.s index 5c2093bd0..6a53f4426 100644 --- a/data/slot_machine.s +++ b/data/slot_machine.s @@ -2,52 +2,7 @@ .include "constants/constants.inc" .section .rodata - .align 2 -gUnknown_8464974:: - .incbin "graphics/slot_machine/unk_8464974.gbapal" - -gUnknown_8464994:: - .incbin "graphics/slot_machine/unk_8464994.gbapal" - -gUnknown_84649B4:: - .incbin "graphics/slot_machine/unk_84649b4.gbapal" - -gUnknown_84649D4:: - .incbin "graphics/slot_machine/unk_84649d4.gbapal" - -gUnknown_84649F4:: - .incbin "graphics/slot_machine/unk_84649f4.gbapal" - -gUnknown_8464A14:: - .incbin "graphics/slot_machine/unk_8464a14.4bpp.lz" - -gUnknown_846504C:: - .incbin "graphics/slot_machine/unk_846504c.gbapal" - -gUnknown_846506C:: - .incbin "graphics/slot_machine/unk_846506c.4bpp.lz" - -gUnknown_8465524:: - .incbin "graphics/slot_machine/unk_8465524.gbapal" - -gUnknown_8465544:: - .incbin "graphics/slot_machine/unk_8465544.4bpp.lz" - -gUnknown_84655B0:: @ 84655B0 - obj_tiles gUnknown_8464A14, 0x0e00, 0 - obj_tiles gUnknown_846506C, 0x0c00, 1 - obj_tiles gUnknown_8465544, 0x0280, 2 - -gUnknown_84655C8:: @ 84655C8 - obj_pal gUnknown_8464974, 0 - obj_pal gUnknown_8464994, 1 - obj_pal gUnknown_84649B4, 2 - obj_pal gUnknown_84649D4, 3 - obj_pal gUnknown_84649F4, 4 - obj_pal gUnknown_846504C, 5 - obj_pal gUnknown_8465524, 6 - null_obj_pal - + .align 1 gUnknown_8465608:: @ 8465608 .2byte 0x0002, 0x0002, 0x0000, 0x0000, 0x0002, 0x0004, 0x0003 diff --git a/src/slot_machine.c b/src/slot_machine.c index 172a4014a..129d9b79a 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -1,5 +1,6 @@ #include "global.h" #include "palette.h" +#include "decompress.h" #include "task.h" #include "main.h" #include "malloc.h" @@ -33,7 +34,15 @@ struct SlotMachineState u16 payout; }; +struct SlotMachineGfxManager +{ + u32 field_00[3]; + u32 field_0C[3][5]; + u8 filler_4C[0x2C]; +}; + EWRAM_DATA struct SlotMachineState * sSlotMachineState = NULL; +EWRAM_DATA struct SlotMachineGfxManager * gUnknown_203F3A4 = NULL; void sub_813F84C(struct SlotMachineState * ptr); void sub_813F898(void); @@ -60,6 +69,7 @@ bool32 sub_81408F4(s32, s32); void sub_81409B4(void); void sub_8140A70(void); u16 sub_8140A80(void); +void sub_8140C6C(struct SlotMachineGfxManager * manager); void sub_8140D7C(s16 *, s16 *); bool32 sub_814104C(void); void sub_8141094(void); @@ -130,6 +140,34 @@ const u16 gUnknown_8464966[] = { 300 }; +const u16 gUnknown_8464974[] = INCBIN_U16("graphics/slot_machine/unk_8464974.gbapal"); +const u16 gUnknown_8464994[] = INCBIN_U16("graphics/slot_machine/unk_8464994.gbapal"); +const u16 gUnknown_84649B4[] = INCBIN_U16("graphics/slot_machine/unk_84649b4.gbapal"); +const u16 gUnknown_84649D4[] = INCBIN_U16("graphics/slot_machine/unk_84649d4.gbapal"); +const u16 gUnknown_84649F4[] = INCBIN_U16("graphics/slot_machine/unk_84649f4.gbapal"); +const u32 gUnknown_8464A14[] = INCBIN_U32("graphics/slot_machine/unk_8464a14.4bpp.lz"); +const u16 gUnknown_846504C[] = INCBIN_U16("graphics/slot_machine/unk_846504c.gbapal"); +const u32 gUnknown_846506C[] = INCBIN_U32("graphics/slot_machine/unk_846506c.4bpp.lz"); +const u16 gUnknown_8465524[] = INCBIN_U16("graphics/slot_machine/unk_8465524.gbapal"); +const u32 gUnknown_8465544[] = INCBIN_U32("graphics/slot_machine/unk_8465544.4bpp.lz"); + +const struct CompressedSpriteSheet gUnknown_84655B0[] = { + {(const void *)gUnknown_8464A14, 0xe00, 0}, + {(const void *)gUnknown_846506C, 0xc00, 1}, + {(const void *)gUnknown_8465544, 0x280, 2}, +}; + +const struct SpritePalette gUnknown_84655C8[] = { + {gUnknown_8464974, 0}, + {gUnknown_8464994, 1}, + {gUnknown_84649B4, 2}, + {gUnknown_84649D4, 3}, + {gUnknown_84649F4, 4}, + {gUnknown_846504C, 5}, + {gUnknown_8465524, 6}, + {NULL} +}; + void PlaySlotMachine(u16 machineIdx, MainCallback savedCallback) { ResetTasks(); @@ -1322,3 +1360,55 @@ u16 sub_8140A80(void) } return r9; } + +u16 sub_8140BDC(void) +{ + return sSlotMachineState->payout; +} + +u8 sub_8140BEC(void) +{ + return sSlotMachineState->bet; +} + +bool32 sub_8140BF8(s32 a0) +{ + return sSlotMachineState->field_3C[a0]; +} + +bool32 sub_8140C0C(void) +{ + s32 i; + + for (i = 0; i < NELEMS(gUnknown_84655B0); i++) + LoadCompressedObjectPic(&gUnknown_84655B0[i]); + LoadSpritePalettes(gUnknown_84655C8); + gUnknown_203F3A4 = Alloc(sizeof(*gUnknown_203F3A4)); + if (gUnknown_203F3A4 == NULL) + return FALSE; + sub_8140C6C(gUnknown_203F3A4); + return TRUE; +} + +void sub_8140C50(void) +{ + if (gUnknown_203F3A4 != NULL) + { + Free(gUnknown_203F3A4); + gUnknown_203F3A4 = NULL; + } +} + +void sub_8140C6C(struct SlotMachineGfxManager * manager) +{ + s32 i, j; + + for (i = 0; i < 3; i++) + { + manager->field_00[i] = 0; + for (j = 0; j < 5; j++) + { + manager->field_0C[i][j] = 0; + } + } +} diff --git a/sym_ewram.txt b/sym_ewram.txt index fa2499ace..18f6433c4 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1592,9 +1592,6 @@ gUnknown_203F39C: @ 203F39C .align 2 .include "src/slot_machine.o" -gUnknown_203F3A4: @ 203F3A4 - .space 0x4 - sLocationHistory: @ 203F3A8 .space 0x6 |