function EventLoopCoroutine()
    dialogCoroutine = coroutine.create(function()
        loadBackground("res/backgrounds/Backgrounds (SPHIA)/BG_B05E1.png", 0)
        loadBackground("res/backgrounds/Backgrounds (SPHIA)/BG_B07N1.png", 1)
        loadBackground("res/backgrounds/Backgrounds (SPHIA)/BG_B19N3.png", 2)
        loadBackground("res/backgrounds/Backgrounds (SPHIA)/BG_B20N2.png", 3)
        loadMusic("res/music/08 - Persona.mp3")
        loadCharacter("res/characters/Naoya Enamoto/EN01AS.png", 0)
        local currentTime = getTime()
        while getTime() - currentTime < 1.5 do
            drawText("End of the End: Beginning", 100, 100, 30)
            coroutine.yield()
        end
        playMusic()
        drawBackground(getScreenWidth()/2, getScreenHeight()/2, 1.68, 0)
        dialogBox({
            "2011, January 11th.",
            "[Self] What should I do...",
            "[Self] Situation is getting worse and worse.",
            "[Self] If Leiblich plan succeed, this means that somehow I can get inside her mind...",
            "[Self] I should go into basement.",
        }, {})
        while isDialogExecuted() do
            coroutine.yield()
        end
        stopDrawBackground(0)
        while getTime() - currentTime < 0.4 do
            coroutine.yield()
        end
        drawBackground(getScreenWidth()/2, getScreenHeight()/2, 1.68, 1)
        local currentTime = getTime()
        while getTime() - currentTime < 0.6 do
            coroutine.yield()
        end
        stopDrawBackground(1)
        local currentTime = getTime()
        while getTime() - currentTime < 0.6 do
            coroutine.yield()
        end
        drawBackground(getScreenWidth()/2, getScreenHeight()/2, 1.68, 2)
        local currentTime = getTime()
        while getTime() - currentTime < 0.6 do
            coroutine.yield()
        end
        stopDrawBackground(2)
        local currentTime = getTime()
        while getTime() - currentTime < 0.6 do
            coroutine.yield()
        end
        drawBackground(getScreenWidth()/2, getScreenHeight()/2, 1.68, 3)
        dialogBox({
            "[Satoru] You're finally appeared."
        }, {})
        while isDialogExecuted() do
            coroutine.yield()
        end
        drawCharacter(getScreenWidth()/2, getScreenHeight()/2, 2.1, 0)
        dialogBox({
            "[Self] You can see me?",
            "[Satoru] I'm the one who summoned you, so yes.",
            "[Self] Why?! Why must I suffer? Why must I see everything from this violence, cruelty, deaths, and so on?",
            "[Self] I didn't want to see anyone suffers...",
            "[Satoru] You should save my sister. Then everything will stop, and future would be fixed.",
            "[Self] But... How?",
            "[Satoru] Go to beach and wait for a some time. Then, you should enter a cube, that would appear. Inside, touch black box.",
            "[Self] I see..."
        }, {})
        while isDialogExecuted() do
            coroutine.yield()
        end
        stopDrawBackground(3)
        stopDrawCharacter(0)
        stopMusic()
        local currentTime = getTime()
        while getTime() - currentTime < 0.4 do
            coroutine.yield()
        end
        unloadMusic()
        unloadBackground(0)
        unloadBackground(1)
        unloadBackground(2)
        unloadBackground(3)
        unloadCharacter(0)
        loadScript("scripts/SE09.lua")
    end)
end

function EventLoop()
    if dialogCoroutine and coroutine.status(dialogCoroutine) ~= "dead" then
        coroutine.resume(dialogCoroutine)
    end
end

setFont("res/InterTight-Regular.ttf")
EventLoopCoroutine()