diff options
author | Matthew Wozniak <me@woz.blue> | 2024-10-25 23:24:45 -0400 |
---|---|---|
committer | Matthew Wozniak <me@woz.blue> | 2024-10-25 23:24:45 -0400 |
commit | 36b6d84ee4b520bdf43891ea86df03cf660cb464 (patch) | |
tree | 3aa78d9b1a3f04c0aeaaf86c8a60106115bf5c85 | |
download | rt-36b6d84ee4b520bdf43891ea86df03cf660cb464.tar.gz rt-36b6d84ee4b520bdf43891ea86df03cf660cb464.zip |
create project
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | LICENSE | 13 | ||||
-rw-r--r-- | Makefile | 15 | ||||
-rw-r--r-- | README | 7 | ||||
-rw-r--r-- | intdef.h | 16 | ||||
-rw-r--r-- | log.h | 18 | ||||
-rw-r--r-- | main.c | 24 | ||||
-rw-r--r-- | os.h | 20 |
8 files changed, 117 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..165f4d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +compile_flags.txt
+*.o
+*.pdb
+*.exe
@@ -0,0 +1,13 @@ +Copyright (c) 2024 Matthew Wozniak <me@woz.blue>
+
+Permission to use, copy, modify, and/or distribute this software for any purpose
+with or without fee is hereby granted, provided that the above copyright notice
+and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..91fdac8 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +CC = clang
+CFLAGS = -g -O2 -target i686-windows-msvc -include stdbool.h
+LDFLAGS = -g -fuse-ld=lld -O2 -m32
+OBJS = main.o
+
+all: rt.exe
+
+rt.exe: $(OBJS)
+ $(CC) $(LDFLAGS) $(OBJS) -o rt.exe
+
+%.o: %.c
+ $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
+
+clean:
+ rm -f *.o *.exe *.pdb
@@ -0,0 +1,7 @@ +rendertools
+-----------
+
+orange box engine demo renderer
+
+usage:
+ rt -w <width> -h <height> -g <game> -r <fps> path/to/demo.dem
diff --git a/intdef.h b/intdef.h new file mode 100644 index 0000000..03a8ac3 --- /dev/null +++ b/intdef.h @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: ISC
+// SPDX-FileCopyrightText: 2024 Matthew Wozniak <me@woz.blue>
+
+#ifndef INTDEF_H
+#define INTDEF_H
+
+typedef unsigned char byte;
+typedef unsigned short ushort;
+typedef unsigned int uint;
+typedef unsigned long ulong;
+typedef long long vlong;
+typedef unsigned long long uvlong;
+
+#endif
+
+// vi: sw=4 ts=4 noet tw=80 cc=80
@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: ISC
+// SPDX-FileCopyrightText: 2024 Matthew Wozniak <me@woz.blue>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define die(fmt, ...) {\
+ fprintf(stderr, "err: " __FILE__ ": " fmt "\n", __VA_ARGS__); \
+ exit(1); \
+}
+
+#define warn(fmt, ...) \
+ fprintf(stderr, "warn: " __FILE__ ": " fmt "\n", __VA_ARGS__)
+
+#define info(fmt, ...) \
+ fprintf(stderr, "info: " __FILE__ ": " fmt "\n", __VA_ARGS__)
+
+// vi: sw=4 ts=4 noet tw=80 cc=80
@@ -0,0 +1,24 @@ +// SPDX-License-Identifier: ISC
+// SPDX-FileCopyrightText: 2024 Matthew Wozniak <me@woz.blue>
+
+#include "os.h"
+#include "log.h"
+
+#include <Windows.h>
+#include <stddef.h>
+
+typedef int (*LauncherMain_t)(void *instance, void *prev_inst, char *cmdline,
+ int cmd_show);
+
+int main(int argc, char **argv) {
+ SetDllDirectoryA("bin/");
+
+ void *launcher_dll = os_dlopen("launcher");
+ LauncherMain_t launcher_main =
+ (LauncherMain_t)os_dlsym(launcher_dll, "LauncherMain");
+
+ if (!launcher_main) die("couldn't open launcher");
+ launcher_main(NULL, NULL, NULL, 0);
+}
+
+// vi: sw=4 ts=4 noet tw=80 cc=80
@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: ISC
+// SPDX-FileCopyrightText: 2024 Matthew Wozniak <me@woz.blue>
+
+#ifndef OS_H
+#define OS_H
+
+#include <Windows.h>
+#include "intdef.h"
+
+#define os_dlopen LoadLibraryA
+#define os_dlsym GetProcAddress
+
+inline bool os_mprot(void *mem, int len, int mode) {
+ ulong old;
+ return !!VirtualProtect(mem, len, mode, &old);
+}
+
+#endif
+
+// vi: sw=4 ts=4 noet tw=80 cc=80
|