10 static int parse_args(int argc, char **argv);
12 static struct video_mode *vidmode;
14 int main(int argc, char **argv)
20 read_config("rbench.cfg");
22 if(parse_args(argc, argv) == -1) {
27 __djgpp_nearptr_enable();
30 init_logger("rbench.log");
32 if(init_video() == -1) {
36 if((vmidx = match_video_mode(opt.width, opt.height, opt.bpp)) == -1) {
39 if(!(vmem = set_video_mode(vmidx, 1))) {
42 vidmode = get_video_mode(vmidx);
44 fb_rmask = vidmode->rmask;
45 fb_gmask = vidmode->gmask;
46 fb_bmask = vidmode->bmask;
47 fb_rshift = vidmode->rshift;
48 fb_gshift = vidmode->gshift;
49 fb_bshift = vidmode->bshift;
60 time_msec = get_msec();
64 blit_frame(framebuf, 0);
72 printf("avg framerate: %.1f fps\n", (10000 * num_frames / time_msec) / 10.0f);
77 int resizefb(int x, int y, int bpp)
84 fb_pitch = x * bpp / 8;
86 if(!(framebuf = malloc(fb_pitch * fb_height))) {
87 fprintf(stderr, "failed to allocate %dx%d (%dbpp) framebuffer\n",
88 fb_width, fb_height, fb_bpp);
94 static const char *usage_str =
95 "Usage: %s [options]\n"
97 " -s <WxH>: resolution\n"
98 " -b <bpp>: color depth\n"
99 " -h: print usage and exit\n";
101 static int parse_args(int argc, char **argv)
105 for(i=1; i<argc; i++) {
106 if(argv[i][0] == '-') {
112 if(!argv[++i] || sscanf(argv[i], "%dx%d", &opt.width, &opt.height) != 2) {
113 fprintf(stderr, "-s must be followed by WxH\n");
119 if(!argv[++i] || !(opt.bpp = atoi(argv[i]))) {
120 fprintf(stderr, "-b must be followed by the color depth\n");
126 printf(usage_str, argv[0]);
133 inval_arg: fprintf(stderr, "invalid argument: %s\n", argv[i]);