blank dos build
authorJohn Tsiombikas <nuclear@member.fsf.org>
Mon, 17 May 2021 22:28:13 +0000 (01:28 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Mon, 17 May 2021 22:28:13 +0000 (01:28 +0300)
Makefile.dj [new file with mode: 0644]
src/dos/main.c [new file with mode: 0644]
src/rbench.c
src/util.h
tools/lutgen.c
tools/pack.bat [new file with mode: 0644]

diff --git a/Makefile.dj b/Makefile.dj
new file mode 100644 (file)
index 0000000..fc59199
--- /dev/null
@@ -0,0 +1,41 @@
+src = $(wildcard src/*.c) $(wildcard src/dos/*.c)
+ssrc = sinlut.s
+obj = $(src:.c=.o) $(ssrc:.s=.o)
+dep = $(src:.c=.d)
+bin = rbench.exe
+
+LUTGEN = tools/lutgen.exe
+
+warn = -pedantic -Wall -Wno-deprecated-declarations
+dbg = -g
+opt = -O3 -ffast-math
+inc = -Isrc
+def = -DNO_STDINT_H
+
+CFLAGS = -pedantic $(warn) $(dbg) $(opt) $(def) $(inc) -MMD
+
+$(bin): $(obj)
+       $(CC) -o $@ $(obj) $(LDFLAGS)
+
+sinlut.s: $(LUTGEN)
+       $(LUTGEN) >$@
+
+-include $(dep)
+-include *.d
+
+.PHONY: clean
+clean:
+       del src\*.o
+       del src\dos\*.o
+       del *.o
+       del $(bin)
+       del sinlut.s
+
+.PHONY: cleandep
+cleandep:
+       del src\*.d
+       del src\dos\*.d
+       del *.d
+
+$(LUTGEN): tools/lutgen.c
+       $(CC) -o $@ $< -lm
diff --git a/src/dos/main.c b/src/dos/main.c
new file mode 100644 (file)
index 0000000..5a1a13a
--- /dev/null
@@ -0,0 +1,66 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "rbench.h"
+
+static int parse_args(int argc, char **argv);
+
+int main(int argc, char **argv)
+{
+       read_config("rbench.cfg");
+
+       if(parse_args(argc, argv) == -1) {
+               return 1;
+       }
+
+       printf("foo %dx%d %dbpp\n", opt.width, opt.height, opt.bpp);
+
+       return 0;
+}
+
+
+static const char *usage_str =
+       "Usage: %s [options]\n"
+       "Options:\n"
+       "  -s <WxH>: resolution\n"
+       "  -b <bpp>: color depth\n"
+       "  -h: print usage and exit\n";
+
+static int parse_args(int argc, char **argv)
+{
+       int i;
+
+       for(i=1; i<argc; i++) {
+               if(argv[i][0] == '-') {
+                       if(argv[i][2]) {
+                               goto inval_arg;
+                       }
+                       switch(argv[i][1]) {
+                       case 's':
+                               if(!argv[++i] || sscanf(argv[i], "%dx%d", &opt.width, &opt.height) != 2) {
+                                       fprintf(stderr, "-s must be followed by WxH\n");
+                                       return -1;
+                               }
+                               break;
+
+                       case 'b':
+                               if(!argv[++i] || !(opt.bpp = atoi(argv[i]))) {
+                                       fprintf(stderr, "-b must be followed by the color depth\n");
+                                       return -1;
+                               }
+                               break;
+
+                       case 'h':
+                               printf(usage_str, argv[0]);
+                               exit(0);
+
+                       default:
+                               goto inval_arg;
+                       }
+               } else {
+inval_arg:     fprintf(stderr, "invalid argument: %s\n", argv[i]);
+                       return -1;
+               }
+       }
+       return 0;
+}
+
index 4a2c232..7202c1a 100644 (file)
@@ -1,6 +1,5 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdint.h>
 #include <math.h>
 #include "rbench.h"
 #include "treestor.h"
index 9b04f0d..9f0eb4d 100644 (file)
@@ -1,6 +1,17 @@
 #ifndef UTIL_H_
 #define UTIL_H_
 
+#ifdef NO_STDINT_H
+typedef char int8_t;
+typedef unsigned char uint8_t;
+typedef short int16_t;
+typedef unsigned short uint16_t;
+typedef int int32_t;
+typedef unsigned int uint32_t;
+#else
+#include <stdint.h>
+#endif
+
 extern int sinlut[];
 
 #define SIN(x) sinlut[(x) & 0xff]
index b4f2645..a573de1 100644 (file)
@@ -6,7 +6,9 @@ int main(void)
        int i;
 
        puts("\t.data");
+       puts("\t.globl _sinlut");
        puts("\t.globl sinlut");
+       puts("_sinlut:");
        puts("sinlut:");
        for(i=0; i<256; i++) {
                float x = sin((float)i / 128.0f * M_PI);
diff --git a/tools/pack.bat b/tools/pack.bat
new file mode 100644 (file)
index 0000000..7fddfeb
--- /dev/null
@@ -0,0 +1,13 @@
+deltree /y c:\tmp\rbench
+mkdir c:\tmp\rbench
+mkdir c:\tmp\rbench\src
+mkdir c:\tmp\rbench\src\dos
+mkdir c:\tmp\rbench\tools
+
+copy Makefile.dos c:\tmp\rbench
+copy tools\lutgen.c c:\tmp\rbench\tools
+copy src\*.c c:\tmp\rbench\src
+copy src\*.h c:\tmp\rbench\src
+copy src\dos\*.c c:\tmp\rbench\src\dos
+copy src\dos\*.h c:\tmp\rbench\src\dos
+copy pack.bat c:\tmp\rbench