summaryrefslogtreecommitdiff
path: root/src/field_fadetransition.c
blob: b5e6c10396a05f2c4769953ed5a9f475666c88e7 (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
#include "global.h"
#include "gba/syscall.h"
#include "field_weather.h"
#include "global.fieldmap.h"
#include "script.h"
#include "task.h"

void palette_bg_fill_white(void);
void palette_bg_fill_black(void);
void pal_fill_black(void);
void task0A_asap_script_env_2_enable_and_set_ctx_running(u8);

extern u8 get_map_light_from_warp0(void);
extern u8 sav1_map_get_light_level(void);
extern u8 fade_type_for_given_maplight_pair(u8, u8);
extern u16 gPlttBufferFaded[];
extern struct MapHeader * warp1_get_mapheader(void);
extern void sub_8059B88(u8);
extern void sub_8053E90(void);

extern u8 sub_810CDB8(u8, u8);
extern int sub_8080E70(void);

void palette_bg_fill_white(void)
{
    u32 source_color = 0x7fff7fff;
    CpuFastSet(&source_color, gPlttBufferFaded, 0x100 | (1 << 24));
}

void palette_bg_fill_black(void)
{
    u32 source_color = 0;
    CpuFastSet(&source_color, gPlttBufferFaded, 0x100 | (1 << 24));
}

void pal_fill_for_map_transition(void)
{
    u8 map_light = get_map_light_from_warp0();
    switch (fade_type_for_given_maplight_pair(map_light, sav1_map_get_light_level()))
    {
    case 0:
        fade_screen(0, 0);
        palette_bg_fill_black();
        break;
    case 1:
        fade_screen(2, 0);
        palette_bg_fill_white();
    }
}

void pal_fill_black(void)
{
    fade_screen(0, 0);
    palette_bg_fill_black();
}

void fade_8080918(void)
{
    u8 light_level = sav1_map_get_light_level();
    switch (sub_810CDB8(light_level, warp1_get_mapheader()->mapType))
    {
    case 0:
        fade_screen(1, 0);
        break;
    case 1:
        fade_screen(3, 0);
    }
}

void sub_8080958(u8 arg)
{
    sub_8059B88(!arg);
}

void task0A_asap_script_env_2_enable_and_set_ctx_running(u8 taskID)
{
    if (sub_8080E70() == 1)
    {
        DestroyTask(taskID);
        EnableBothScriptContexts();
    }
}

void sub_8080990(void)
{
    ScriptContext2_Enable();
    sub_8053E90();
    pal_fill_black();
    CreateTask(&task0A_asap_script_env_2_enable_and_set_ctx_running, 0x0a);
}

void sub_80809B0(void)
{
    ScriptContext2_Enable();
    pal_fill_black();
    CreateTask(&task0A_asap_script_env_2_enable_and_set_ctx_running, 0x0a);
}