about summary refs log tree commit diff stats
path: root/premake5.lua
blob: c88e9cce08cdcb7649b234d1f338d94dc959499c (plain) (blame)
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
workspace("Pong")
    configurations {"Release"}

project("Pong")
    newaction {
        trigger = "install",
        description = "Install the game to prefix.",
        execute = function()
	    os.mkdir(string.format("%s/Pong/resources", prefix))
	    os.executef("cp -r resources/* %s/Pong/resources/", prefix)
        os.executef("install -m755 bin/*/Pong %s/Pong/pong", prefix)
        os.exit(0)
        end
    }

    newaction {
        trigger = "check_deps",
        description = "Check if you have all the dependencies installed.",
        execute = function()
            io.write("Pkgconf: ")
            io.flush()
            Pkgconf_Result = os.executef("which pkgconf")
            AllGood = true
            if(Pkgconf_Result == nil)
            then
                print("You do not have pkgconf installed. Aborting.")
                os.exit(1)
            end
            io.write("Raylib: ")
            io.flush()
            if(os.executef("pkgconf --modversion raylib") == nil)
            then
                print("Can't find raylib.")
                AllGood = false
            end
            io.write("SDL2: ")
            io.flush()
            if(os.executef("pkgconf --modversion sdl2") == nil)
            then
                print("Can't find SDL2.")
                AllGood = false
            end
            io.write("SDL2_mixer: ")
            io.flush()
            if (os.executef("pkgconf --modversion SDL2_mixer") == nil)
            then
                print("Can't find SDL2_mixer.")
                AllGood = false
            end
            io.write("GLFW3: ")
            io.flush()
            if (os.executef("pkgconf --modversion glfw3") == nil)
            then
                print("Can't find GLFW.")
                AllGood = false
            end
	    io.write("GL: ")
	    io.flush()
	    if (os.executef("pkgconf --modversion gl") == nil)
	    then
		    print("Can't find OpenGL")
		    AllGood = false
	    end
	    io.write("GLU: ")
	    io.flush()
	    if (os.executef("pkgconf --modversion glu") == nil)
	    then
		    print("Can't find GLU")
		    AllGood = false
	    end
            if(AllGood == true)
            then
                print("Found all dependencies!")
                os.exit(0)
            end
            print("Failed to find all needed dependencies.")
            os.exit(1)
        end
    }

    kind("WindowedApp")
    optimize("Debug")
    language("C")
    files {"src/*.c", "src/*.h", }
    --libdirs {"/usr/local/lib", "/usr/pkg/lib", "/usr/X11R7/include"}

    -- Prefix Option
    newoption {
        trigger     = "prefix",
        value       = "path",
        description = "Prefix for where the game is to be installed."
    }
    prefix = _OPTIONS["prefix"] or "app"

    -- Flatpak
    newoption {
        trigger     = "flatpak",
        value       = "bool",
        description = "Build a flatpak."
    }
    flatpak = _OPTIONS["flatpak"] or "false"

    if (flatpak == true)
    then
    else
        buildoptions {"-g", "-ggdb", "`pkgconf --cflags raylib`", "`pkgconf --cflags glfw3`", "`pkgconf --cflags gl`", "`pkgconf --cflags sdl2`", "`pkgconf --cflags SDL2_mixer`", "`pkgconf --cflags glu`"}
        linkoptions {"-g", "-ggdb", "`pkgconf --libs raylib`", "`pkgconf --libs glfw3`", "`pkgconf --libs gl`", "`pkgconf --libs sdl2`", "`pkgconf --libs SDL2_mixer`", "`pkgconf --libs glu`"}
    end
    
pan class="w"> file->privateData = (void*)reader; List_Append(gReaders, file); return TRUE; } static void keyboard_close(File *file) { //printkf("keyboard_close\n"); Reader* reader = (Reader*)file->privateData; kfree(reader); List_RemoveFirstOccurrence(gReaders, file); } static int32 keyboard_read(File *file, uint32 size, uint8 *buffer) { Reader* reader = (Reader*)file->privateData; uint32 readIndex = reader->readIndex; if (reader->readMode == Blocking) { while (readIndex == gKeyBufferWriteIndex) { file->thread->state = TS_WAITIO; file->thread->state_privateData = keyboard_read; enableInterrupts(); halt(); } } disableInterrupts(); if (readIndex == gKeyBufferWriteIndex) { //non-blocking return here return -1; } buffer[0] = gKeyBuffer[readIndex]; readIndex++; readIndex %= KEYBUFFER_SIZE; reader->readIndex = readIndex; return 1; } static int32 keyboard_ioctl(File *file, int32 request, void * argp) { Reader* reader = (Reader*)file->privateData; int cmd = (int)argp; switch (request) { case 0: //get *(int*)argp = (int)reader->readMode; return 0; break; case 1: //set if (cmd == 0) { reader->readMode = Blocking; return 0; } else if (cmd == 1) { reader->readMode = NonBlocking; return 0; } break; default: break; } return -1; } static void handleKeyboardInterrupt(Registers *regs) { uint8 scancode = 0; do { scancode = inb(0x64); } while ((scancode & 0x01) == 0); scancode = inb(0x60); gKeyBuffer[gKeyBufferWriteIndex] = scancode; gKeyBufferWriteIndex++; gKeyBufferWriteIndex %= KEYBUFFER_SIZE; //Wake readers List_Foreach(n, gReaders) { File* file = n->data; if (file->thread->state == TS_WAITIO) { if (file->thread->state_privateData == keyboard_read) { file->thread->state = TS_RUN; file->thread->state_privateData = NULL; } } } sendKeyInputToTTY(getActiveTTY(), scancode); }