*.d
*.swp
rbench
+sinlut.s
+tools/lutgen
src = $(wildcard src/*.c) $(wildcard src/x11/*.c)
-obj = $(src:.c=.o)
+ssrc = sinlut.s
+obj = $(src:.c=.o) $(ssrc:.s=.o)
dep = $(src:.c=.d)
bin = rbench
$(bin): $(obj)
$(CC) -o $@ $(obj) $(LDFLAGS)
+sinlut.s: tools/lutgen
+ tools/lutgen >$@
+
-include $(dep)
.PHONY: clean
.PHONY: cleandep
cleandep:
$(RM) $(dep)
+
+tools/lutgen: tools/lutgen.c
+ $(CC) -o $@ $< -lm
#include <math.h>
#include "rbench.h"
#include "treestor.h"
+#include "util.h"
#define DEF_WIDTH 640
#define DEF_HEIGHT 480
unsigned char *fbptr;
uint16_t *fbptr16;
uint32_t *fbptr32;
- float t = (float)time_msec / 1000.0f;
- xoffs = cos(t * 0.5f) * DEF_WIDTH * 2;
- yoffs = sin(t) * DEF_HEIGHT;
- zoom = (sin(t * 0.75f) * 0.5f + 1.0f) * 1024.0f;
+ xoffs = COS(time_msec >> 5) * fb_width >> 7;
+ yoffs = SIN(time_msec >> 4) * fb_height >> 8;
+ zoom = ((SIN(time_msec >> 4) + 256) << 1) + 512;
switch(fb_bpp) {
case 15:
#ifndef UTIL_H_
#define UTIL_H_
+extern int sinlut[];
+
+#define SIN(x) sinlut[(x) & 0xff]
+#define COS(x) sinlut[((x) + 64) & 0xff]
+
int mask_to_shift(unsigned int mask);
#endif /* UTIL_H_ */
--- /dev/null
+#include <stdio.h>
+#include <math.h>
+
+int main(void)
+{
+ int i;
+
+ puts("\t.data");
+ puts("\t.globl sinlut");
+ puts("sinlut:");
+ for(i=0; i<256; i++) {
+ float x = sin((float)i / 128.0f * M_PI);
+ printf("\t.long %d\n", (int)(x * 256.0f));
+ }
+ return 0;
+}