src = $(wildcard src/*.c) $(wildcard src/sdl/*.c)
-obj = $(src:.c=.o)
+obj = $(src:.c=.o) $(asmsrc:.asm=.o)
dep = $(obj:.o=.d)
bin = demo
.PHONY: cleanlibs
cleanlibs:
- $(MAKE) -C libs/imago -f Makefile.dj clean
- $(MAKE) -C libs/oldmik -f Makefile.dj clean
+ $(MAKE) -C libs/imago clean
+ $(MAKE) -C libs/mikmod clean
.PHONY: clean
clean:
src = $(wildcard src/*.c) $(wildcard src/dos/*.c)
+asmsrc = $(wildcard src/*.asm)
obj = $(src:.c=.cof)
dep = $(obj:.cof=.dep)
bin = demo.exe
int sum = sptr[0] * (rad + 1); \
int count = (rad * 2 + 1) << 8; \
int midsize = w - rad * 2; \
+ int firstpix = sptr[0]; \
int lastpix = sptr[pstep * (w - 1)]; \
/* add up the contributions for the -1 pixel */ \
for(j=0; j<rad; j++) { \
sum += sptr[pstep * j]; \
} \
/* first part adding sptr[rad] and subtracting sptr[0] */ \
- for(j=0; j<rad + 1; j++) { \
- sum += (int)sptr[pstep * rad] - (int)sptr[0]; \
+ for(j=0; j<=rad; j++) { \
+ sum += (int)sptr[pstep * rad] - firstpix; \
sptr += pstep; \
*dptr = scale * sum / count; \
dptr += pstep; \
} \
/* middle part adding sptr[rad] and subtracting sptr[-(rad+1)] */ \
- for(j=0; j<midsize - 1; j++) { \
+ for(j=1; j<midsize; j++) { \
sum += (int)sptr[pstep * rad] - (int)sptr[-(rad + 1) * pstep]; \
sptr += pstep; \
*dptr = scale * sum / count; \
#define RAND_FIELD_MAX 0.7
+#define BLUR_RAD 5
+
#define PCOUNT 4000
#define MAX_LIFE 7.0f
#define PALPHA 1.0f
}
}
-#define BLUR_RAD 5
+ /*perf_start();*/
blur_grey_horiz(prev_smokebuf, cur_smokebuf, fb_width, fb_height, BLUR_RAD, 240);
+ /*
+ perf_end();
+ printf("blur perf: %lu\n", (unsigned long)perf_interval_count);
+ */
blur_grey_vert(cur_smokebuf, prev_smokebuf, fb_width, fb_height, BLUR_RAD, 240);
swap_smoke_buffers();
return *(int32_t*)&val;
}
+uint32_t perf_start_count, perf_interval_count;
+
+#ifdef __WATCOMC__
+void perf_start(void);
+#pragma aux perf_start = \
+ "rdtsc" \
+ "mov [perf_start_count], eax" \
+ modify[eax edx];
+
+void perf_end(void);
+#pragma aux perf_end = \
+ "rdtsc" \
+ "sub eax, [perf_start_count]" \
+ "mov [perf_interval_count], eax" \
+ modify [eax edx];
+#endif
+
+#ifdef __GNUC__
+#define perf_start() asm volatile ( \
+ "rdtsc\n" \
+ "mov %%eax, %0\n" \
+ : "=m"(perf_start_count) :: "%eax", "%edx")
+
+#define perf_end() asm volatile ( \
+ "rdtsc\n" \
+ "sub %1, %%eax\n" \
+ "mov %%eax, %0\n" \
+ : "=m"(perf_interval_count) \
+ : "m"(perf_start_count) \
+ : "%eax", "%edx")
+#endif
+
+#ifdef _MSC_VER
+#define perf_start() \
+ do { \
+ __asm { \
+ rdtsc \
+ mov [perf_start_count], eax \
+ } \
+ } while(0)
+
+#define perf_end() \
+ do { \
+ __asm { \
+ rdtsc \
+ sub eax, [perf_start_count] \
+ mov [perf_interval_count], eax \
+ } \
+ } while(0)
+#endif
+
#endif /* UTIL_H_ */