summaryrefslogtreecommitdiff
path: root/arm9/src/options.c
blob: 03b638640b55ba9266fb46eb6d3092fd44a7695d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "global.h"
#include "heap.h"
#include "main.h"
#include "MI_memory.h"
#include "options.h"
#include "player_data.h"

#pragma thumb on

struct Options * Options_new(u32 heap_id) {
    struct Options * ret = AllocFromHeap(heap_id, sizeof(struct Options));
    Options_init(ret);
    return ret;
}

void Options_copy(struct Options * src, struct Options * dest) {
    MI_CpuCopy8(src, dest, sizeof(struct Options));
}

void Options_init(struct Options * options) {
    MI_CpuFill8(options, 0, sizeof(struct Options));

    options->textSpeed = 1;   // mid speed
    options->soundMethod = 0; // stereo
    options->battleStyle = 0; // shift
    options->battleScene = 0; // on
    options->buttonMode = 0;  // normal
    options->frame = 0;       // frame 1
}

void Options_SetButtonModeOnMain(struct SaveBlock2 * sav2, u32 buttonMode) {
    if (sav2 != NULL) {
        buttonMode = Options_GetButtonMode(Sav2_PlayerData_GetOptionsAddr(sav2));
    }

    switch (buttonMode) {
        case 1:
            gMain.buttonMode = 1;
            break;
        case 2:
            gMain.buttonMode = 3;
            break;
        case 0:
        default:
            gMain.buttonMode = 0;
            break;
    }
}

u16 Options_GetTextSpeed(struct Options * options) {
    return options->textSpeed;
}

void Options_SetTextSpeed(struct Options * options, u16 textSpeed) {
    options->textSpeed = (u16)(u32)textSpeed;
}

u32 Options_GetTextFrameDelay(struct Options * options) {
    u16 textSpeed = Options_GetTextSpeed(options);

    if (textSpeed == 0) {
        return 8;
    }

    if (textSpeed == 1) {
        return 4;
    }

    return 1;
}

u16 Options_GetSoundMethod(struct Options * options) {
    return options->soundMethod;
}

void Options_SetSoundMethod(struct Options * options, u16 soundMethod) {
    options->soundMethod = (u16)(u32)soundMethod;
}

u16 Options_GetBattleScene(struct Options * options) {
    return options->battleScene;
}

void Options_SetBattleScene(struct Options * options, u16 battleScene) {
    options->battleScene = (u16)(u32)battleScene;
}

u16 Options_GetBattleStyle(struct Options * options) {
    return options->battleStyle;
}

void Options_SetBattleStyle(struct Options * options, u16 battleStyle) {
    options->battleStyle = (u16)(u32)battleStyle;
}

u16 Options_GetButtonMode(struct Options * options) {
    return options->buttonMode;
}

void Options_SetButtonMode(struct Options * options, u16 buttonMode) {
    options->buttonMode = (u16)(u32)buttonMode;
}

u16 Options_GetFrame(struct Options * options) {
    return options->frame;
}

void Options_SetFrame(struct Options * options, u16 frame) {
    options->frame = (u16)(u32)frame;
}