Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Times of day should be better #10

Open
Jaizu opened this issue Dec 2, 2023 · 0 comments
Open

Times of day should be better #10

Jaizu opened this issue Dec 2, 2023 · 0 comments

Comments

@Jaizu
Copy link

Jaizu commented Dec 2, 2023

By default, the time between 4 and 7 am will return time of day day when its super dark outside
See: https://github.com/aarant/pokeemerald/blob/lighting/src/overworld.c#L1497
image

I suggest this as an alternative

u8 UpdateTimeOfDay(void) {
    s32 hours, minutes;
    RtcCalcLocalTime();
    hours = gLocalTime.hours;
    minutes = gLocalTime.minutes;

    if (hours < 6)
    {
        currentTimeBlend.time0 = TIME_OF_DAY_NIGHT;
        currentTimeBlend.time1 = TIME_OF_DAY_NIGHT;
        currentTimeBlend.weight = 256;
        currentTimeBlend.altWeight = 0;
        gTimeOfDay = TIME_OF_DAY_NIGHT;
        return gTimeOfDay;
    }
    else if (hours < 7)
    {
        currentTimeBlend.time0 = TIME_OF_DAY_NIGHT;
        currentTimeBlend.time1 = TIME_OF_DAY_TWILIGHT;
        currentTimeBlend.weight = 256 - 256 * ((hours - 6) * 60 + minutes) / ((7 - 6) * 60);
        currentTimeBlend.altWeight = (256 - currentTimeBlend.weight) / 2;
        gTimeOfDay = TIME_OF_DAY_TWILIGHT;
        return gTimeOfDay;
    }
    else if (hours < 11)
    {
        currentTimeBlend.time0 = TIME_OF_DAY_TWILIGHT;
        currentTimeBlend.time1 = TIME_OF_DAY_DAY;
        currentTimeBlend.weight = 256 - 256 * ((hours - 7) * 60 + minutes) / ((11 - 7) * 60);
        currentTimeBlend.altWeight = (256 - currentTimeBlend.weight) / 2 + 128;
        gTimeOfDay = TIME_OF_DAY_TWILIGHT;
        return gTimeOfDay;
    }
    else if (hours < 17)
    {
        currentTimeBlend.time0 = TIME_OF_DAY_DAY;
        currentTimeBlend.time1 = TIME_OF_DAY_TWILIGHT;
        currentTimeBlend.weight = 256 - 256 * ((hours - 11) * 60 + minutes) / ((18 - 11) * 60);
        currentTimeBlend.altWeight = currentTimeBlend.weight / 2 + 128;
        gTimeOfDay = TIME_OF_DAY_DAY;
        return gTimeOfDay;
    }
    else if (hours < 21)
    {
        currentTimeBlend.time0 = TIME_OF_DAY_TWILIGHT;
        currentTimeBlend.time1 = TIME_OF_DAY_NIGHT;
        currentTimeBlend.weight = 256 - 256 * ((hours - 18) * 60 + minutes) / ((22 - 18) * 60);
        currentTimeBlend.altWeight = currentTimeBlend.weight / 2;
        gTimeOfDay = TIME_OF_DAY_TWILIGHT;
        return gTimeOfDay;
    }
    else
    {
        currentTimeBlend.time0 = TIME_OF_DAY_NIGHT;
        currentTimeBlend.time1 = TIME_OF_DAY_NIGHT;
        currentTimeBlend.weight = 256;
        currentTimeBlend.altWeight = 0;
        gTimeOfDay = TIME_OF_DAY_NIGHT;
        return gTimeOfDay;
    }
}

Would work like this:
It works like this:
0 - 6 = Night
6 - 7 = Twilight
7 - 11 = Twilight
11 - 17 = Day
17 - 21 = Twilight
12 - 0 = Night

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant