aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--LICENSE13
-rw-r--r--Makefile15
-rw-r--r--README7
-rw-r--r--intdef.h16
-rw-r--r--log.h18
-rw-r--r--main.c24
-rw-r--r--os.h20
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
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..80ef0cf
--- /dev/null
+++ b/LICENSE
@@ -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
diff --git a/README b/README
new file mode 100644
index 0000000..e225edc
--- /dev/null
+++ b/README
@@ -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
diff --git a/log.h b/log.h
new file mode 100644
index 0000000..88254bc
--- /dev/null
+++ b/log.h
@@ -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
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..ae79d3b
--- /dev/null
+++ b/main.c
@@ -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
diff --git a/os.h b/os.h
new file mode 100644
index 0000000..2635268
--- /dev/null
+++ b/os.h
@@ -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