projects
/
dosdemo
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
porting the demo to miniglut
[dosdemo]
/
src
/
dos
/
main.c
diff --git
a/src/dos/main.c
b/src/dos/main.c
index
7564be3
..
566d47e
100644
(file)
--- a/
src/dos/main.c
+++ b/
src/dos/main.c
@@
-1,57
+1,77
@@
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
-#include <math.h>
#include <string.h>
#include <string.h>
-#include <limits.h>
#include "demo.h"
#include "keyb.h"
#include "demo.h"
#include "keyb.h"
-#include "mouse.h"
#include "timer.h"
#include "gfx.h"
#include "timer.h"
#include "gfx.h"
-#include "vmath.h"
-#include "sball.h"
-#include "cfgopt.h"
#include "logger.h"
#include "logger.h"
+#include "cdpmi.h"
+#include "audio.h"
+#include "sball.h"
+#include "vmath.h"
static int handle_sball_event(sball_event *ev);
static void recalc_sball_matrix(float *xform);
static int quit;
static int handle_sball_event(sball_event *ev);
static void recalc_sball_matrix(float *xform);
static int quit;
-static int use_mouse;
-static long fbsize;
+
+int force_snd_config;
static int use_sball;
static vec3_t pos = {0, 0, 0};
static quat_t rot = {0, 0, 0, 1};
static int use_sball;
static vec3_t pos = {0, 0, 0};
static quat_t rot = {0, 0, 0, 1};
+
int main(int argc, char **argv)
{
int main(int argc, char **argv)
{
- fbsize = fb_width * fb_height * fb_bpp / CHAR_BIT;
+ int i;
+ int vmidx, status = 0;
+
+ for(i=1; i<argc; i++) {
+ if(strcmp(argv[i], "-setup") == 0) {
+ force_snd_config = 1;
+ }
+ }
+
+#ifdef __DJGPP__
+ __djgpp_nearptr_enable();
+#endif
init_logger("demo.log");
init_logger("demo.log");
+ /* au_init needs to be called early, before init_timer, and also before
+ * we enter graphics mode, to use the midas configuration tool if necessary
+ */
+ if(au_init() == -1) {
+ return 1;
+ }
+
init_timer(100);
kb_init(32);
init_timer(100);
kb_init(32);
- if((use_mouse = have_mouse())) {
- set_mouse_limits(0, 0, fb_width, fb_height);
- set_mouse(fb_width / 2, fb_height / 2);
+ if(init_video() == -1) {
+ return 1;
}
}
- if(!(fb_pixels = malloc(fbsize))) {
- fprintf(stderr, "failed to allocate backbuffer\n");
+ if((vmidx = match_video_mode(FB_WIDTH, FB_HEIGHT, FB_BPP)) == -1) {
return 1;
}
return 1;
}
-
- if(!(vmem_front = set_video_mode(fb_width, fb_height, fb_bpp))) {
+ if(!(vmem = set_video_mode(vmidx, 1))) {
return 1;
}
return 1;
}
- /* TODO implement multiple video memory pages for flipping */
- vmem_back = vmem_front;
+
+ if(opt.mouse) {
+ if((opt.mouse = have_mouse())) {
+ printf("initializing mouse input\n");
+ set_mouse_limits(0, 0, FB_WIDTH - 1, FB_HEIGHT - 1);
+ set_mouse(FB_WIDTH / 2, FB_HEIGHT / 2);
+ }
+ }
if(demo_init(argc, argv) == -1) {
if(demo_init(argc, argv) == -1) {
- set_text_mode();
- return 1;
+ status = -1;
+ goto break_evloop;
}
if(opt.sball && sball_init() == 0) {
}
if(opt.sball && sball_init() == 0) {
@@
-60,19
+80,18
@@
int main(int argc, char **argv)
reset_timer();
reset_timer();
- while(!quit) {
+ for(;;) {
int key;
while((key = kb_getkey()) != -1) {
demo_keyboard(key, 1);
int key;
while((key = kb_getkey()) != -1) {
demo_keyboard(key, 1);
+ if(quit) goto break_evloop;
}
}
- if(quit) goto break_evloop;
- if(use_mouse) {
+ if(opt.mouse) {
mouse_bmask = read_mouse(&mouse_x, &mouse_y);
}
if(use_sball && sball_pending()) {
sball_event ev;
mouse_bmask = read_mouse(&mouse_x, &mouse_y);
}
if(use_sball && sball_pending()) {
sball_event ev;
- printf("got sball event\n");
while(sball_getevent(&ev)) {
handle_sball_event(&ev);
}
while(sball_getevent(&ev)) {
handle_sball_event(&ev);
}
@@
-84,13
+103,15
@@
int main(int argc, char **argv)
}
break_evloop:
}
break_evloop:
- set_text_mode();
demo_cleanup();
demo_cleanup();
+ set_text_mode();
+ cleanup_video();
kb_shutdown();
kb_shutdown();
+ au_shutdown();
if(use_sball) {
sball_shutdown();
}
if(use_sball) {
sball_shutdown();
}
- return 0;
+ return status;
}
void demo_quit(void)
}
void demo_quit(void)
@@
-98,19
+119,6
@@
void demo_quit(void)
quit = 1;
}
quit = 1;
}
-void swap_buffers(void *pixels)
-{
- /* TODO implement page flipping */
- if(pixels) {
- /*wait_vsync();*/
- drawFps(pixels);
- memcpy(vmem_front, pixels, fbsize);
- } else {
- drawFps(vmem_back);
- }
-}
-
-
#define TX(ev) ((ev)->motion.motion[0])
#define TY(ev) ((ev)->motion.motion[1])
#define TZ(ev) ((ev)->motion.motion[2])
#define TX(ev) ((ev)->motion.motion[0])
#define TY(ev) ((ev)->motion.motion[1])
#define TZ(ev) ((ev)->motion.motion[2])