diff options
author | Daniel Borca <dborca@users.sourceforge.net> | 2005-01-14 08:37:20 +0000 |
---|---|---|
committer | Daniel Borca <dborca@users.sourceforge.net> | 2005-01-14 08:37:20 +0000 |
commit | 7da875d55f6dc9f18e23dd8af9ae7f5782cd3a72 (patch) | |
tree | f14744a4eb497de9045a20726dbf2fdbf474d87b /src/glut | |
parent | f4bff83c3211297159e498c1115b993a5cba9b4b (diff) |
changed coding style
Diffstat (limited to 'src/glut')
-rw-r--r-- | src/glut/dos/PC_HW/pc_hw.c | 178 | ||||
-rw-r--r-- | src/glut/dos/PC_HW/pc_hw.h | 2 | ||||
-rw-r--r-- | src/glut/dos/PC_HW/pc_irq.S | 2 | ||||
-rw-r--r-- | src/glut/dos/PC_HW/pc_keyb.c | 592 | ||||
-rw-r--r-- | src/glut/dos/PC_HW/pc_mouse.c | 269 | ||||
-rw-r--r-- | src/glut/dos/PC_HW/pc_timer.c | 462 | ||||
-rw-r--r-- | src/glut/dos/color.c | 29 | ||||
-rw-r--r-- | src/glut/dos/menu.c | 63 | ||||
-rw-r--r-- | src/glut/dos/mouse.c | 27 | ||||
-rw-r--r-- | src/glut/dos/overlay.c | 60 | ||||
-rw-r--r-- | src/glut/dos/util.c | 52 | ||||
-rw-r--r-- | src/glut/dos/window.c | 335 |
12 files changed, 1049 insertions, 1022 deletions
diff --git a/src/glut/dos/PC_HW/pc_hw.c b/src/glut/dos/PC_HW/pc_hw.c index b1fd84bdb6..100b372165 100644 --- a/src/glut/dos/PC_HW/pc_hw.c +++ b/src/glut/dos/PC_HW/pc_hw.c @@ -1,7 +1,7 @@ /* * PC/HW routine collection v1.3 for DOS/DJGPP * - * Copyright (C) 2002 - Borca Daniel + * Copyright (C) 2002 - Daniel Borca * Email : dborca@yahoo.com * Web : http://www.geocities.com/dborca */ @@ -16,6 +16,7 @@ #include "pc_hw.h" + /* * atexit */ @@ -24,52 +25,61 @@ static volatile int atexitcnt; static VFUNC atexittbl[MAX_ATEXIT]; -static void __attribute__((destructor)) doexit (void) + +static void __attribute__((destructor)) +doexit (void) { - while (atexitcnt) atexittbl[--atexitcnt](); + while (atexitcnt) atexittbl[--atexitcnt](); } -int pc_clexit (VFUNC f) + +int +pc_clexit (VFUNC f) { - int i; - - for (i=0;i<atexitcnt;i++) { - if (atexittbl[i]==f) { - for (atexitcnt--;i<atexitcnt;i++) atexittbl[i] = atexittbl[i+1]; - atexittbl[i] = 0; - return 0; - } - } - return -1; + int i; + + for (i = 0; i < atexitcnt; i++) { + if (atexittbl[i] == f) { + for (atexitcnt--; i < atexitcnt; i++) atexittbl[i] = atexittbl[i+1]; + atexittbl[i] = 0; + return 0; + } + } + return -1; } -int pc_atexit (VFUNC f) + +int +pc_atexit (VFUNC f) { - pc_clexit(f); - if (atexitcnt<MAX_ATEXIT) { - atexittbl[atexitcnt++] = f; - return 0; - } - return -1; + pc_clexit(f); + if (atexitcnt < MAX_ATEXIT) { + atexittbl[atexitcnt++] = f; + return 0; + } + return -1; } + /* * locked memory allocation */ -void *pc_malloc (size_t size) +void * +pc_malloc (size_t size) { - void *p = malloc(size); + void *p = malloc(size); - if (p) { - if (_go32_dpmi_lock_data(p, size)) { - free(p); - return NULL; - } - } + if (p) { + if (_go32_dpmi_lock_data(p, size)) { + free(p); + return NULL; + } + } - return p; + return p; } + /* * standard redirection */ @@ -78,68 +88,76 @@ static int h_out, h_outbak; static char errname[L_tmpnam]; static int h_err, h_errbak; -int pc_open_stdout (void) + +int +pc_open_stdout (void) { - tmpnam(outname); + tmpnam(outname); - if ((h_out=open(outname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) { - h_outbak = dup(STDOUT_FILENO); - fflush(stdout); - dup2(h_out, STDOUT_FILENO); - } + if ((h_out=open(outname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) { + h_outbak = dup(STDOUT_FILENO); + fflush(stdout); + dup2(h_out, STDOUT_FILENO); + } - return h_out; + return h_out; } -void pc_close_stdout (void) + +void +pc_close_stdout (void) { - FILE *f; - char *line = alloca(512); - - if (h_out > 0) { - dup2(h_outbak, STDOUT_FILENO); - close(h_out); - close(h_outbak); - - f = fopen(outname, "rt"); - while (fgets(line, 512, f)) { - fputs(line, stdout); - } - fclose(f); - - remove(outname); - } + FILE *f; + char *line = alloca(512); + + if (h_out > 0) { + dup2(h_outbak, STDOUT_FILENO); + close(h_out); + close(h_outbak); + + f = fopen(outname, "rt"); + while (fgets(line, 512, f)) { + fputs(line, stdout); + } + fclose(f); + + remove(outname); + } } -int pc_open_stderr (void) + +int +pc_open_stderr (void) { - tmpnam(errname); + tmpnam(errname); - if ((h_err=open(errname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) { - h_errbak = dup(STDERR_FILENO); - fflush(stderr); - dup2(h_err, STDERR_FILENO); - } + if ((h_err=open(errname, O_WRONLY | O_CREAT | O_TEXT | O_TRUNC, S_IREAD | S_IWRITE)) > 0) { + h_errbak = dup(STDERR_FILENO); + fflush(stderr); + dup2(h_err, STDERR_FILENO); + } - return h_err; + return h_err; } -void pc_close_stderr (void) + +void +pc_close_stderr (void) { - FILE *f; - char *line = alloca(512); - - if (h_err > 0) { - dup2(h_errbak, STDERR_FILENO); - close(h_err); - close(h_errbak); - - f = fopen(errname, "rt"); - while (fgets(line, 512, f)) { - fputs(line, stderr); - } - fclose(f); - - remove(errname); - } + FILE *f; + char *line = alloca(512); + + if (h_err > 0) { + dup2(h_errbak, STDERR_FILENO); + close(h_err); + close(h_errbak); + + f = fopen(errname, "rt"); + while (fgets(line, 512, f)) { + fputs(line, stderr); + } + fclose(f); + + remove(errname); + } } diff --git a/src/glut/dos/PC_HW/pc_hw.h b/src/glut/dos/PC_HW/pc_hw.h index bd2293eb29..41948ec991 100644 --- a/src/glut/dos/PC_HW/pc_hw.h +++ b/src/glut/dos/PC_HW/pc_hw.h @@ -1,7 +1,7 @@ /* * PC/HW routine collection v1.4 for DOS/DJGPP * - * Copyright (C) 2002 - Borca Daniel + * Copyright (C) 2002 - Daniel Borca * Email : dborca@yahoo.com * Web : http://www.geocities.com/dborca */ diff --git a/src/glut/dos/PC_HW/pc_irq.S b/src/glut/dos/PC_HW/pc_irq.S index 6d99bd805e..7d62ac74ce 100644 --- a/src/glut/dos/PC_HW/pc_irq.S +++ b/src/glut/dos/PC_HW/pc_irq.S @@ -1,7 +1,7 @@ /* * PC/HW routine collection v1.3 for DOS/DJGPP * - * Copyright (C) 2002 - Borca Daniel + * Copyright (C) 2002 - Daniel Borca * Email : dborca@yahoo.com * Web : http://www.geocities.com/dborca */ diff --git a/src/glut/dos/PC_HW/pc_keyb.c b/src/glut/dos/PC_HW/pc_keyb.c index d3c87bc5bd..d7e3257b9d 100644 --- a/src/glut/dos/PC_HW/pc_keyb.c +++ b/src/glut/dos/PC_HW/pc_keyb.c @@ -1,7 +1,7 @@ /* * PC/HW routine collection v1.3 for DOS/DJGPP * - * Copyright (C) 2002 - Borca Daniel + * Copyright (C) 2002 - Daniel Borca * Email : dborca@yahoo.com * Web : http://www.geocities.com/dborca */ @@ -14,7 +14,6 @@ #include "pc_hw.h" - #define KEYB_IRQ 1 #define KEY_BUFFER_SIZE 64 @@ -25,8 +24,8 @@ static int keyboard_installed; static volatile struct { - volatile int start, end; - volatile int key[KEY_BUFFER_SIZE]; + volatile int start, end; + volatile int key[KEY_BUFFER_SIZE]; } key_buffer; static volatile int key_enhanced, key_pause_loop, key_shifts; @@ -35,10 +34,8 @@ static int in_a_terrupt = FALSE; static volatile char pc_key[KEY_MAX]; - /* convert Allegro format scancodes into key_shifts flag bits */ -static unsigned short modifier_table[KEY_MAX - KEY_MODIFIERS] = -{ +static unsigned short modifier_table[KEY_MAX - KEY_MODIFIERS] = { KB_SHIFT_FLAG, KB_SHIFT_FLAG, KB_CTRL_FLAG, KB_CTRL_FLAG, KB_ALT_FLAG, KB_ALT_FLAG, KB_LWIN_FLAG, KB_RWIN_FLAG, KB_MENU_FLAG, @@ -46,10 +43,8 @@ static unsigned short modifier_table[KEY_MAX - KEY_MODIFIERS] = }; - /* lookup table for converting hardware scancodes into Allegro format */ -static unsigned char hw_to_mycode[128] = -{ +static unsigned char hw_to_mycode[128] = { /* 0x00 */ 0, KEY_ESC, KEY_1, KEY_2, /* 0x04 */ KEY_3, KEY_4, KEY_5, KEY_6, /* 0x08 */ KEY_7, KEY_8, KEY_9, KEY_0, @@ -85,10 +80,8 @@ static unsigned char hw_to_mycode[128] = }; - /* lookup table for converting extended hardware codes into Allegro format */ -static unsigned char hw_to_mycode_ex[128] = -{ +static unsigned char hw_to_mycode_ex[128] = { /* 0x00 */ 0, KEY_ESC, KEY_1, KEY_2, /* 0x04 */ KEY_3, KEY_4, KEY_5, KEY_6, /* 0x08 */ KEY_7, KEY_8, KEY_9, KEY_0, @@ -124,10 +117,8 @@ static unsigned char hw_to_mycode_ex[128] = }; - /* default mapping table for the US keyboard layout */ -static unsigned short standard_key_ascii_table[KEY_MAX] = -{ +static unsigned short standard_key_ascii_table[KEY_MAX] = { /* start */ 0, /* alphabet */ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', /* numbers */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', @@ -140,10 +131,8 @@ static unsigned short standard_key_ascii_table[KEY_MAX] = }; - /* capslock mapping table for the US keyboard layout */ -static unsigned short standard_key_capslock_table[KEY_MAX] = -{ +static unsigned short standard_key_capslock_table[KEY_MAX] = { /* start */ 0, /* alphabet */ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', /* numbers */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', @@ -156,10 +145,8 @@ static unsigned short standard_key_capslock_table[KEY_MAX] = }; - /* shifted mapping table for the US keyboard layout */ -static unsigned short standard_key_shift_table[KEY_MAX] = -{ +static unsigned short standard_key_shift_table[KEY_MAX] = { /* start */ 0, /* alphabet */ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', /* numbers */ ')', '!', '@', '#', '$', '%', '^', '&', '*', '(', @@ -172,10 +159,8 @@ static unsigned short standard_key_shift_table[KEY_MAX] = }; - /* ctrl+key mapping table for the US keyboard layout */ -static unsigned short standard_key_control_table[KEY_MAX] = -{ +static unsigned short standard_key_control_table[KEY_MAX] = { /* start */ 0, /* alphabet */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, /* numbers */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -188,215 +173,217 @@ static unsigned short standard_key_control_table[KEY_MAX] = }; - /* convert numeric pad scancodes into arrow codes */ -static unsigned char numlock_table[10] = -{ +static unsigned char numlock_table[10] = { KEY_INSERT, KEY_END, KEY_DOWN, KEY_PGDN, KEY_LEFT, KEY_5_PAD, KEY_RIGHT, KEY_HOME, KEY_UP, KEY_PGUP }; - /* kb_wait_for_write_ready: * Wait for the keyboard controller to set the ready-for-write bit. */ -static __inline int kb_wait_for_write_ready (void) +static __inline int +kb_wait_for_write_ready (void) { - int timeout = 4096; + int timeout = 4096; - while ((timeout>0) && (inportb(0x64)&2)) timeout--; + while ((timeout > 0) && (inportb(0x64) & 2)) timeout--; - return (timeout>0); + return (timeout > 0); } - /* kb_wait_for_read_ready: * Wait for the keyboard controller to set the ready-for-read bit. */ -static __inline int kb_wait_for_read_ready (void) +static __inline int +kb_wait_for_read_ready (void) { - int timeout = 16384; + int timeout = 16384; - while ((timeout>0) && (!(inportb(0x64)&1))) timeout--; + while ((timeout > 0) && (!(inportb(0x64) & 1))) timeout--; - return (timeout>0); + return (timeout > 0); } - /* kb_send_data: * Sends a byte to the keyboard controller. Returns 1 if all OK. */ -static __inline int kb_send_data (unsigned char data) +static __inline int +kb_send_data (unsigned char data) { - int resends = 4; - int timeout, temp; + int resends = 4; + int timeout, temp; - do { - if (!kb_wait_for_write_ready()) - return 0; + do { + if (!kb_wait_for_write_ready()) + return 0; - outportb(0x60, data); - timeout = 4096; + outportb(0x60, data); + timeout = 4096; - while (--timeout>0) { - if (!kb_wait_for_read_ready()) - return 0; + while (--timeout > 0) { + if (!kb_wait_for_read_ready()) + return 0; - temp = inportb(0x60); + temp = inportb(0x60); - if (temp == 0xFA) - return 1; + if (temp == 0xFA) + return 1; - if (temp == 0xFE) - break; - } - } while ((resends-- > 0) && (timeout > 0)); + if (temp == 0xFE) + break; + } + } while ((resends-- > 0) && (timeout > 0)); - return 0; + return 0; } - -static void update_leds (int leds) +static void +update_leds (int leds) { - if (leds_ok) { - if (!in_a_terrupt) - DISABLE(); - - if (!kb_send_data(0xED)) { - kb_send_data(0xF4); - leds_ok = FALSE; - } else if (!kb_send_data((leds>>8)&7)) { - kb_send_data(0xF4); - leds_ok = FALSE; - } - - if (!in_a_terrupt) - ENABLE(); - } + if (leds_ok) { + if (!in_a_terrupt) + DISABLE(); + + if (!kb_send_data(0xED)) { + kb_send_data(0xF4); + leds_ok = FALSE; + } else if (!kb_send_data((leds >> 8) & 7)) { + kb_send_data(0xF4); + leds_ok = FALSE; + } + + if (!in_a_terrupt) + ENABLE(); + } } ENDOFUNC(update_leds) - -static void inject_key (int scancode) +static void +inject_key (int scancode) { - unsigned short *table; - - if ((scancode >= KEY_0_PAD) && (scancode <= KEY_9_PAD)) { - if (((key_shifts & KB_NUMLOCK_FLAG) != 0) == ((key_shifts & KB_SHIFT_FLAG) != 0)) { - scancode = numlock_table[scancode - KEY_0_PAD]; - } - table = standard_key_ascii_table; - } else if (key_shifts & KB_CTRL_FLAG) { - table = standard_key_control_table; - } else if (key_shifts & KB_SHIFT_FLAG) { - if (key_shifts & KB_CAPSLOCK_FLAG) { - if (standard_key_ascii_table[scancode]==standard_key_capslock_table[scancode]) { - table = standard_key_shift_table; - } else { - table = standard_key_ascii_table; - } - } else { - table = standard_key_shift_table; - } - } else if (key_shifts & KB_CAPSLOCK_FLAG) { - table = standard_key_capslock_table; - } else { - table = standard_key_ascii_table; - } - - key_buffer.key[key_buffer.end++] = (scancode<<16)|table[scancode]; - - if (key_buffer.end>=KEY_BUFFER_SIZE) - key_buffer.end = 0; - if (key_buffer.end==key_buffer.start) { - key_buffer.start++; - if (key_buffer.start>=KEY_BUFFER_SIZE) - key_buffer.start = 0; - } + unsigned short *table; + + if ((scancode >= KEY_0_PAD) && (scancode <= KEY_9_PAD)) { + if (((key_shifts & KB_NUMLOCK_FLAG) != 0) == ((key_shifts & KB_SHIFT_FLAG) != 0)) { + scancode = numlock_table[scancode - KEY_0_PAD]; + } + table = standard_key_ascii_table; + } else if (key_shifts & KB_CTRL_FLAG) { + table = standard_key_control_table; + } else if (key_shifts & KB_SHIFT_FLAG) { + if (key_shifts & KB_CAPSLOCK_FLAG) { + if (standard_key_ascii_table[scancode] == standard_key_capslock_table[scancode]) { + table = standard_key_shift_table; + } else { + table = standard_key_ascii_table; + } + } else { + table = standard_key_shift_table; + } + } else if (key_shifts & KB_CAPSLOCK_FLAG) { + table = standard_key_capslock_table; + } else { + table = standard_key_ascii_table; + } + + key_buffer.key[key_buffer.end++] = (scancode << 16) | table[scancode]; + + if (key_buffer.end >= KEY_BUFFER_SIZE) + key_buffer.end = 0; + if (key_buffer.end == key_buffer.start) { + key_buffer.start++; + if (key_buffer.start >= KEY_BUFFER_SIZE) + key_buffer.start = 0; + } } ENDOFUNC(inject_key) -static void handle_code (int scancode, int keycode) + +static void +handle_code (int scancode, int keycode) { - in_a_terrupt++; - - if (keycode==0) { /* pause */ - inject_key(scancode); - pc_key[KEY_PAUSE] ^= TRUE; - } else if (scancode) { - int flag; - - if (scancode>=KEY_MODIFIERS) { - flag = modifier_table[scancode - KEY_MODIFIERS]; - } else { - flag = 0; - } - if ((char)keycode<0) { /* release */ - pc_key[scancode] = FALSE; - if (flag&KB_MODIFIERS) { - key_shifts &= ~flag; - } - } else { /* keypress */ - pc_key[scancode] = TRUE; - if (flag&KB_MODIFIERS) { - key_shifts |= flag; - } - if (flag&KB_LED_FLAGS) { - key_shifts ^= flag; - update_leds(key_shifts); - } - if (scancode<KEY_MODIFIERS) { - inject_key(scancode); - } - } - } - - in_a_terrupt--; + in_a_terrupt++; + + if (keycode == 0) { /* pause */ + inject_key(scancode); + pc_key[KEY_PAUSE] ^= TRUE; + } else if (scancode) { + int flag; + + if (scancode >= KEY_MODIFIERS) { + flag = modifier_table[scancode - KEY_MODIFIERS]; + } else { + flag = 0; + } + if ((char)keycode < 0) { /* release */ + pc_key[scancode] = FALSE; + if (flag & KB_MODIFIERS) { + key_shifts &= ~flag; + } + } else { /* keypress */ + pc_key[scancode] = TRUE; + if (flag & KB_MODIFIERS) { + key_shifts |= flag; + } + if (flag & KB_LED_FLAGS) { + key_shifts ^= flag; + update_leds(key_shifts); + } + if (scancode < KEY_MODIFIERS) { + inject_key(scancode); + } + } + } + + in_a_terrupt--; } ENDOFUNC(handle_code) -static int keyboard () + +static int +keyboard () { - unsigned char temp, scancode; - - temp = inportb(0x60); - - if (temp<=0xe1) { - if (key_pause_loop) { - if (!--key_pause_loop) handle_code(KEY_PAUSE, 0); - } else - switch (temp) { - case 0xe0: - key_enhanced = TRUE; - break; - case 0xe1: - key_pause_loop = 5; - break; - default: - if (key_enhanced) { - key_enhanced = FALSE; - scancode = hw_to_mycode_ex[temp&0x7f]; - } else { - scancode = hw_to_mycode[temp&0x7f]; - } - handle_code(scancode, temp); - } - } - - if (((temp==0x4F)||(temp==0x53))&&(key_shifts&KB_CTRL_FLAG)&&(key_shifts&KB_ALT_FLAG)) { - /* Hack alert: - only SIGINT (but not Ctrl-Break) - calls the destructors and will safely clean up - */ - __asm("\n\ + unsigned char temp, scancode; + + temp = inportb(0x60); + + if (temp <= 0xe1) { + if (key_pause_loop) { + if (!--key_pause_loop) handle_code(KEY_PAUSE, 0); + } else + switch (temp) { + case 0xe0: + key_enhanced = TRUE; + break; + case 0xe1: + key_pause_loop = 5; + break; + default: + if (key_enhanced) { + key_enhanced = FALSE; + scancode = hw_to_mycode_ex[temp & 0x7f]; + } else { + scancode = hw_to_mycode[temp & 0x7f]; + } + handle_code(scancode, temp); + } + } + + if (((temp==0x4F)||(temp==0x53))&&(key_shifts&KB_CTRL_FLAG)&&(key_shifts&KB_ALT_FLAG)) { + /* Hack alert: + * only SIGINT (but not Ctrl-Break) + * calls the destructors and will safely clean up + */ + __asm("\n\ movb $0x79, %%al \n\ call ___djgpp_hw_exception \n\ - ":::"%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"); - } + ":::"%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"); + } - __asm("\n\ + __asm("\n\ inb $0x61, %%al \n\ movb %%al, %%ah \n\ orb $0x80, %%al \n\ @@ -405,138 +392,149 @@ static int keyboard () outb %%al, $0x61 \n\ movb $0x20, %%al \n\ outb %%al, $0x20 \n\ - ":::"%eax"); - return 0; + ":::"%eax"); + return 0; } ENDOFUNC(keyboard) -int pc_keypressed (void) +int +pc_keypressed (void) { - return (key_buffer.start!=key_buffer.end); + return (key_buffer.start!=key_buffer.end); } -int pc_readkey (void) + +int +pc_readkey (void) { - if (keyboard_installed) { - int key; - - while (key_buffer.start==key_buffer.end) { - __dpmi_yield(); - } - - DISABLE(); - key = key_buffer.key[key_buffer.start++]; - if (key_buffer.start>=KEY_BUFFER_SIZE) - key_buffer.start = 0; - ENABLE(); - - return key; - } else { - return 0; - } + if (keyboard_installed) { + int key; + + while (key_buffer.start == key_buffer.end) { + __dpmi_yield(); + } + + DISABLE(); + key = key_buffer.key[key_buffer.start++]; + if (key_buffer.start >= KEY_BUFFER_SIZE) + key_buffer.start = 0; + ENABLE(); + + return key; + } else { + return 0; + } } -int pc_keydown (int code) + +int +pc_keydown (int code) { - return pc_key[code]; + return pc_key[code]; } -int pc_keyshifts (void) + +int +pc_keyshifts (void) { - return key_shifts; + return key_shifts; } -void pc_remove_keyb (void) + +void +pc_remove_keyb (void) { - if (keyboard_installed) { - int s1, s2, s3; - - keyboard_installed = FALSE; - pc_clexit(pc_remove_keyb); - - DISABLE(); - _farsetsel(__djgpp_dos_sel); - _farnspokew(0x41c, _farnspeekw(0x41a)); - - s1 = _farnspeekb(0x417) & 0x80; - s2 = _farnspeekb(0x418) & 0xFC; - s3 = _farnspeekb(0x496) & 0xF3; - - if (pc_key[KEY_RSHIFT]) { s1 |= 1; } - if (pc_key[KEY_LSHIFT]) { s1 |= 2; } - if (pc_key[KEY_LCONTROL]) { s2 |= 1; s1 |= 4; } - if (pc_key[KEY_ALT]) { s1 |= 8; s2 |= 2; } - if (pc_key[KEY_RCONTROL]) { s1 |= 4; s3 |= 4; } - if (pc_key[KEY_ALTGR]) { s1 |= 8; s3 |= 8; } - - if (key_shifts&KB_SCROLOCK_FLAG) s1 |= 16; - if (key_shifts&KB_NUMLOCK_FLAG) s1 |= 32; - if (key_shifts&KB_CAPSLOCK_FLAG) s1 |= 64; - - _farnspokeb(0x417, s1); - _farnspokeb(0x418, s2); - _farnspokeb(0x496, s3); - update_leds(key_shifts); - - ENABLE(); - pc_remove_irq(KEYB_IRQ); - } + if (keyboard_installed) { + int s1, s2, s3; + + keyboard_installed = FALSE; + pc_clexit(pc_remove_keyb); + + DISABLE(); + _farsetsel(__djgpp_dos_sel); + _farnspokew(0x41c, _farnspeekw(0x41a)); + + s1 = _farnspeekb(0x417) & 0x80; + s2 = _farnspeekb(0x418) & 0xFC; + s3 = _farnspeekb(0x496) & 0xF3; + + if (pc_key[KEY_RSHIFT]) { s1 |= 1; } + if (pc_key[KEY_LSHIFT]) { s1 |= 2; } + if (pc_key[KEY_LCONTROL]) { s2 |= 1; s1 |= 4; } + if (pc_key[KEY_ALT]) { s1 |= 8; s2 |= 2; } + if (pc_key[KEY_RCONTROL]) { s1 |= 4; s3 |= 4; } + if (pc_key[KEY_ALTGR]) { s1 |= 8; s3 |= 8; } + + if (key_shifts & KB_SCROLOCK_FLAG) s1 |= 16; + if (key_shifts & KB_NUMLOCK_FLAG) s1 |= 32; + if (key_shifts & KB_CAPSLOCK_FLAG) s1 |= 64; + + _farnspokeb(0x417, s1); + _farnspokeb(0x418, s2); + _farnspokeb(0x496, s3); + update_leds(key_shifts); + + ENABLE(); + pc_remove_irq(KEYB_IRQ); + } } -int pc_install_keyb (void) + +int +pc_install_keyb (void) { - if (keyboard_installed||pc_install_irq(KEYB_IRQ, keyboard)) { - return -1; - } else { - int s1, s2, s3; - - LOCKDATA(key_buffer); - LOCKDATA(key_enhanced); - LOCKDATA(key_pause_loop); - LOCKDATA(key_shifts); - LOCKDATA(leds_ok); - LOCKDATA(in_a_terrupt); - LOCKDATA(pc_key); - LOCKDATA(modifier_table); - LOCKDATA(hw_to_mycode); - LOCKDATA(hw_to_mycode_ex); - LOCKDATA(standard_key_ascii_table); - LOCKDATA(standard_key_capslock_table); - LOCKDATA(standard_key_shift_table); - LOCKDATA(standard_key_control_table); - LOCKDATA(numlock_table); - LOCKFUNC(update_leds); - LOCKFUNC(inject_key); - LOCKFUNC(handle_code); - LOCKFUNC(keyboard); - - DISABLE(); - _farsetsel(__djgpp_dos_sel); - _farnspokew(0x41c, _farnspeekw(0x41a)); - - key_shifts = 0; - s1 = _farnspeekb(0x417); - s2 = _farnspeekb(0x418); - s3 = _farnspeekb(0x496); - - if (s1&1) { key_shifts |= KB_SHIFT_FLAG; pc_key[KEY_RSHIFT] = TRUE; } - if (s1&2) { key_shifts |= KB_SHIFT_FLAG; pc_key[KEY_LSHIFT] = TRUE; } - if (s2&1) { key_shifts |= KB_CTRL_FLAG; pc_key[KEY_LCONTROL] = TRUE; } - if (s2&2) { key_shifts |= KB_ALT_FLAG; pc_key[KEY_ALT] = TRUE; } - if (s3&4) { key_shifts |= KB_CTRL_FLAG; pc_key[KEY_RCONTROL] = TRUE; } - if (s3&8) { key_shifts |= KB_ALT_FLAG; pc_key[KEY_ALTGR] = TRUE; } - - if (s1&16) key_shifts |= KB_SCROLOCK_FLAG; - if (s1&32) key_shifts |= KB_NUMLOCK_FLAG; - if (s1&64) key_shifts |= KB_CAPSLOCK_FLAG; - update_leds(key_shifts); - - key_enhanced = key_pause_loop = 0; - key_buffer.start = key_buffer.end = 0; - ENABLE(); - - pc_atexit(pc_remove_keyb); - keyboard_installed = TRUE; - return 0; - } + if (keyboard_installed || pc_install_irq(KEYB_IRQ, keyboard)) { + return -1; + } else { + int s1, s2, s3; + + LOCKDATA(key_buffer); + LOCKDATA(key_enhanced); + LOCKDATA(key_pause_loop); + LOCKDATA(key_shifts); + LOCKDATA(leds_ok); + LOCKDATA(in_a_terrupt); + LOCKDATA(pc_key); + LOCKDATA(modifier_table); + LOCKDATA(hw_to_mycode); + LOCKDATA(hw_to_mycode_ex); + LOCKDATA(standard_key_ascii_table); + LOCKDATA(standard_key_capslock_table); + LOCKDATA(standard_key_shift_table); + LOCKDATA(standard_key_control_table); + LOCKDATA(numlock_table); + LOCKFUNC(update_leds); + LOCKFUNC(inject_key); + LOCKFUNC(handle_code); + LOCKFUNC(keyboard); + + DISABLE(); + _farsetsel(__djgpp_dos_sel); + _farnspokew(0x41c, _farnspeekw(0x41a)); + + key_shifts = 0; + s1 = _farnspeekb(0x417); + s2 = _farnspeekb(0x418); + s3 = _farnspeekb(0x496); + + if (s1 & 1) { key_shifts |= KB_SHIFT_FLAG; pc_key[KEY_RSHIFT] = TRUE; } + if (s1 & 2) { key_shifts |= KB_SHIFT_FLAG; pc_key[KEY_LSHIFT] = TRUE; } + if (s2 & 1) { key_shifts |= KB_CTRL_FLAG; pc_key[KEY_LCONTROL] = TRUE; } + if (s2 & 2) { key_shifts |= KB_ALT_FLAG; pc_key[KEY_ALT] = TRUE; } + if (s3 & 4) { key_shifts |= KB_CTRL_FLAG; pc_key[KEY_RCONTROL] = TRUE; } + if (s3 & 8) { key_shifts |= KB_ALT_FLAG; pc_key[KEY_ALTGR] = TRUE; } + + if (s1 & 16) key_shifts |= KB_SCROLOCK_FLAG; + if (s1 & 32) key_shifts |= KB_NUMLOCK_FLAG; + if (s1 & 64) key_shifts |= KB_CAPSLOCK_FLAG; + update_leds(key_shifts); + + key_enhanced = key_pause_loop = 0; + key_buffer.start = key_buffer.end = 0; + ENABLE(); + + pc_atexit(pc_remove_keyb); + keyboard_installed = TRUE; + return 0; + } } diff --git a/src/glut/dos/PC_HW/pc_mouse.c b/src/glut/dos/PC_HW/pc_mouse.c index fc0902ce81..5bf99d367f 100644 --- a/src/glut/dos/PC_HW/pc_mouse.c +++ b/src/glut/dos/PC_HW/pc_mouse.c @@ -1,7 +1,7 @@ /* * PC/HW routine collection v1.3 for DOS/DJGPP * - * Copyright (C) 2002 - Borca Daniel + * Copyright (C) 2002 - Daniel Borca * Email : dborca@yahoo.com * Web : http://www.geocities.com/dborca */ @@ -14,16 +14,15 @@ #include "pc_hw.h" - #define PC_CUTE_WHEEL 1 /* CuteMouse WheelAPI */ #define MOUSE_STACK_SIZE 16384 #define CLEAR_MICKEYS() \ - do { \ - __asm __volatile ("movw $0xb, %%ax; int $0x33":::"%eax", "%ecx", "%edx"); \ - ox = oy = 0; \ - } while (0) + do { \ + __asm __volatile ("movw $0xb, %%ax; int $0x33":::"%eax", "%ecx", "%edx"); \ + ox = oy = 0; \ + } while (0) extern void mouse_wrap (void); extern int mouse_wrap_end[]; @@ -33,7 +32,7 @@ static long mouse_callback; static __dpmi_regs mouse_regs; static volatile struct { - volatile int x, y, z, b; + volatile int x, y, z, b; } pc_mouse; static int minx = 0; @@ -51,41 +50,44 @@ static int emulat3 = FALSE; static int ox, oy; -static void mouse (__dpmi_regs *r) +static void +mouse (__dpmi_regs *r) { - int nx = (signed short)r->x.si / sx; - int ny = (signed short)r->x.di / sy; - int dx = nx - ox; - int dy = ny - oy; + int nx = (signed short)r->x.si / sx; + int ny = (signed short)r->x.di / sy; + int dx = nx - ox; + int dy = ny - oy; #if PC_CUTE_WHEEL - int dz = (signed char)r->h.bh; + int dz = (signed char)r->h.bh; #endif - ox = nx; - oy = ny; + ox = nx; + oy = ny; - pc_mouse.b = r->h.bl; - pc_mouse.x = MID(minx, pc_mouse.x + dx, maxx); - pc_mouse.y = MID(miny, pc_mouse.y + dy, maxy); + pc_mouse.b = r->h.bl; + pc_mouse.x = MID(minx, pc_mouse.x + dx, maxx); + pc_mouse.y = MID(miny, pc_mouse.y + dy, maxy); #if PC_CUTE_WHEEL - pc_mouse.z = MID(minz, pc_mouse.z + dz, maxz); + pc_mouse.z = MID(minz, pc_mouse.z + dz, maxz); #endif - if (emulat3) { - if ((pc_mouse.b&3)==3) { - pc_mouse.b = 4; - } - } + if (emulat3) { + if ((pc_mouse.b & 3) == 3) { + pc_mouse.b = 4; + } + } - if (mouse_func) { - mouse_func(pc_mouse.x, pc_mouse.y, pc_mouse.z, pc_mouse.b); - } + if (mouse_func) { + mouse_func(pc_mouse.x, pc_mouse.y, pc_mouse.z, pc_mouse.b); + } } ENDOFUNC(mouse) -void pc_remove_mouse (void) + +void +pc_remove_mouse (void) { - if (mouse_callback) { - pc_clexit(pc_remove_mouse); - __asm("\n\ + if (mouse_callback) { + pc_clexit(pc_remove_mouse); + __asm("\n\ movl %%edx, %%ecx \n\ shrl $16, %%ecx \n\ movw $0x0304, %%ax \n\ @@ -93,61 +95,63 @@ void pc_remove_mouse (void) movw $0x000c, %%ax \n\ xorl %%ecx, %%ecx \n\ int $0x33 \n\ - "::"d"(mouse_callback):"%eax", "%ecx"); + "::"d"(mouse_callback):"%eax", "%ecx"); - mouse_callback = 0; + mouse_callback = 0; - free((void *)(mouse_wrap_end[0] - MOUSE_STACK_SIZE)); - } + free((void *)(mouse_wrap_end[0] - MOUSE_STACK_SIZE)); + } } -int pc_install_mouse (void) + +int +pc_install_mouse (void) { - int buttons; + int buttons; - /* fail if already call-backed */ - if (mouse_callback) { - return 0; - } + /* fail if already call-backed */ + if (mouse_callback) { + return 0; + } - /* reset mouse and get status */ - __asm("\n\ + /* reset mouse and get status */ + __asm("\n\ xorl %%eax, %%eax \n\ int $0x33 \n\ andl %%ebx, %%eax \n\ movl %%eax, %0 \n\ - ":"=g" (buttons)::"%eax", "%ebx"); - if (!buttons) { - return 0; - } - - /* lock wrapper */ - LOCKDATA(mouse_func); - LOCKDATA(mouse_callback); - LOCKDATA(mouse_regs); - LOCKDATA(pc_mouse); - LOCKDATA(minx); - LOCKDATA(maxx); - LOCKDATA(miny); - LOCKDATA(maxy); - LOCKDATA(minz); - LOCKDATA(maxz); - LOCKDATA(sx); - LOCKDATA(sy); - LOCKDATA(emulat3); - LOCKDATA(ox); - LOCKDATA(oy); - LOCKFUNC(mouse); - LOCKFUNC(mouse_wrap); - - mouse_wrap_end[1] = __djgpp_ds_alias; - /* grab a locked stack */ - if ((mouse_wrap_end[0] = (int)pc_malloc(MOUSE_STACK_SIZE)) == NULL) { - return 0; - } - - /* try to hook a call-back */ - __asm("\n\ + ":"=g" (buttons)::"%eax", "%ebx"); + if (!buttons) { + return 0; + } + + /* lock wrapper */ + LOCKDATA(mouse_func); + LOCKDATA(mouse_callback); + LOCKDATA(mouse_regs); + LOCKDATA(pc_mouse); + LOCKDATA(minx); + LOCKDATA(maxx); + LOCKDATA(miny); + LOCKDATA(maxy); + LOCKDATA(minz); + LOCKDATA(maxz); + LOCKDATA(sx); + LOCKDATA(sy); + LOCKDATA(emulat3); + LOCKDATA(ox); + LOCKDATA(oy); + LOCKFUNC(mouse); + LOCKFUNC(mouse_wrap); + + mouse_wrap_end[1] = __djgpp_ds_alias; + /* grab a locked stack */ + if ((mouse_wrap_end[0] = (int)pc_malloc(MOUSE_STACK_SIZE)) == NULL) { + return 0; + } + + /* try to hook a call-back */ + __asm("\n\ pushl %%ds \n\ pushl %%es \n\ movw $0x0303, %%ax \n\ @@ -163,86 +167,97 @@ int pc_install_mouse (void) movw %%dx, %%cx \n\ movl %%ecx, %0 \n\ 0: \n\ - ":"=g"(mouse_callback) - :"S" (mouse_wrap), "D"(&mouse_regs) - :"%eax", "%ecx", "%edx"); - if (!mouse_callback) { - free((void *)mouse_wrap_end[0]); - return 0; - } - - /* adjust stack */ - mouse_wrap_end[0] += MOUSE_STACK_SIZE; - - /* install the handler */ - mouse_regs.x.ax = 0x000c; + ":"=g"(mouse_callback) + :"S" (mouse_wrap), "D"(&mouse_regs) + :"%eax", "%ecx", "%edx"); + if (!mouse_callback) { + free((void *)mouse_wrap_end[0]); + return 0; + } + + /* adjust stack */ + mouse_wrap_end[0] += MOUSE_STACK_SIZE; + + /* install the handler */ + mouse_regs.x.ax = 0x000c; #if PC_CUTE_WHEEL - mouse_regs.x.cx = 0x7f | 0x80; + mouse_regs.x.cx = 0x7f | 0x80; #else - mouse_regs.x.cx = 0x7f; + mouse_regs.x.cx = 0x7f; #endif - mouse_regs.x.dx = mouse_callback&0xffff; - mouse_regs.x.es = mouse_callback>>16; - __dpmi_int(0x33, &mouse_regs); + mouse_regs.x.dx = mouse_callback & 0xffff; + mouse_regs.x.es = mouse_callback >> 16; + __dpmi_int(0x33, &mouse_regs); - CLEAR_MICKEYS(); + CLEAR_MICKEYS(); - emulat3 = buttons<3; - pc_atexit(pc_remove_mouse); - return buttons; + emulat3 = (buttons < 3); + pc_atexit(pc_remove_mouse); + return buttons; } -MFUNC pc_install_mouse_handler (MFUNC handler) + +MFUNC +pc_install_mouse_handler (MFUNC handler) { - MFUNC old; + MFUNC old; - if (!mouse_callback && !pc_install_mouse()) { - return NULL; - } + if (!mouse_callback && !pc_install_mouse()) { + return NULL; + } - old = mouse_func; - mouse_func = handler; - return old; + old = mouse_func; + mouse_func = handler; + return old; } -void pc_mouse_area (int x1, int y1, int x2, int y2) + +void +pc_mouse_area (int x1, int y1, int x2, int y2) { - minx = x1; - maxx = x2; - miny = y1; - maxy = y2; + minx = x1; + maxx = x2; + miny = y1; + maxy = y2; } -void pc_mouse_speed (int xspeed, int yspeed) + +void +pc_mouse_speed (int xspeed, int yspeed) { - DISABLE(); + DISABLE(); - sx = MAX(1, xspeed); - sy = MAX(1, yspeed); + sx = MAX(1, xspeed); + sy = MAX(1, yspeed); - ENABLE(); + ENABLE(); } -int pc_query_mouse (int *x, int *y, int *z) + +int +pc_query_mouse (int *x, int *y, int *z) { - *x = pc_mouse.x; - *y = pc_mouse.y; - *z = pc_mouse.z; - return pc_mouse.b; + *x = pc_mouse.x; + *y = pc_mouse.y; + *z = pc_mouse.z; + return pc_mouse.b; } -void pc_warp_mouse (int x, int y) + +void +pc_warp_mouse (int x, int y) { - CLEAR_MICKEYS(); + CLEAR_MICKEYS(); - pc_mouse.x = MID(minx, x, maxx); - pc_mouse.y = MID(miny, y, maxy); + pc_mouse.x = MID(minx, x, maxx); + pc_mouse.y = MID(miny, y, maxy); - if (mouse_func) { - mouse_func(pc_mouse.x, pc_mouse.y, pc_mouse.z, pc_mouse.b); - } + if (mouse_func) { + mouse_func(pc_mouse.x, pc_mouse.y, pc_mouse.z, pc_mouse.b); + } } + /* Hack alert: * `mouse_wrap_end' actually holds the * address of stack in a safe data selector. diff --git a/src/glut/dos/PC_HW/pc_timer.c b/src/glut/dos/PC_HW/pc_timer.c index 530ed72a49..e7cbe70a1f 100644 --- a/src/glut/dos/PC_HW/pc_timer.c +++ b/src/glut/dos/PC_HW/pc_timer.c @@ -1,7 +1,7 @@ /* * PC/HW routine collection v1.5 for DOS/DJGPP * - * Copyright (C) 2002 - Borca Daniel + * Copyright (C) 2002 - Daniel Borca * Email : dborca@yahoo.com * Web : http://www.geocities.com/dborca */ @@ -25,15 +25,14 @@ static int timer_installed; typedef struct { - volatile unsigned int counter, clock_ticks, freq; - volatile PFUNC func; - volatile void *parm; + volatile unsigned int counter, clock_ticks, freq; + volatile PFUNC func; + volatile void *parm; } TIMER; static TIMER timer_main, timer_func[MAX_TIMERS]; - /* Desc: main timer callback * * In : - @@ -41,33 +40,33 @@ static TIMER timer_main, timer_func[MAX_TIMERS]; * * Note: - */ -static int timer () +static int +timer () { - int i; - - for (i = 0; i < MAX_TIMERS; i++) { - TIMER *t = &timer_func[i]; - if (t->func) { - t->clock_ticks += t->counter; - if (t->clock_ticks >= timer_main.counter) { - t->clock_ticks -= timer_main.counter; - t->func(unvolatile(t->parm, void *)); - } - } - } - - timer_main.clock_ticks += timer_main.counter; - if (timer_main.clock_ticks >= 0x10000) { - timer_main.clock_ticks -= 0x10000; - return 1; - } else { - outportb(0x20, 0x20); - return 0; - } + int i; + + for (i = 0; i < MAX_TIMERS; i++) { + TIMER *t = &timer_func[i]; + if (t->func) { + t->clock_ticks += t->counter; + if (t->clock_ticks >= timer_main.counter) { + t->clock_ticks -= timer_main.counter; + t->func(unvolatile(t->parm, void *)); + } + } + } + + timer_main.clock_ticks += timer_main.counter; + if (timer_main.clock_ticks >= 0x10000) { + timer_main.clock_ticks -= 0x10000; + return 1; + } else { + outportb(0x20, 0x20); + return 0; + } } ENDOFUNC(timer) - /* Desc: uninstall timer engine * * In : - @@ -75,24 +74,24 @@ static int timer () * * Note: - */ -void pc_remove_timer (void) +void +pc_remove_timer (void) { - if (timer_installed) { - timer_installed = FALSE; - pc_clexit(pc_remove_timer); - - DISABLE(); - outportb(0x43, 0x34); - outportb(0x40, 0); - outportb(0x40, 0); - ENABLE(); - - pc_remove_irq(TIMER_IRQ); - } + if (timer_installed) { + timer_installed = FALSE; + pc_clexit(pc_remove_timer); + + DISABLE(); + outportb(0x43, 0x34); + outportb(0x40, 0); + outportb(0x40, 0); + ENABLE(); + + pc_remove_irq(TIMER_IRQ); + } } - /* Desc: remove timerfunc * * In : timerfunc id @@ -100,65 +99,65 @@ void pc_remove_timer (void) * * Note: tries to relax the main timer whenever possible */ -int pc_remove_int (int fid) +int +pc_remove_int (int fid) { - int i; - unsigned int freq = 0; - - /* are we installed? */ - if (!timer_installed) { - return -1; - } - - /* sanity check */ - if ((fid < 0) || (fid >= MAX_TIMERS) || (timer_func[fid].func == NULL)) { - return -1; - } - timer_func[fid].func = NULL; - - /* scan for maximum frequency */ - for (i = 0; i < MAX_TIMERS; i++) { - TIMER *t = &timer_func[i]; - if (t->func) { - if (freq < t->freq) { - freq = t->freq; - } - } - } - - /* if there are no callbacks left, cleanup */ - if (!freq) { - pc_remove_timer(); - return 0; - } - - /* if we just lowered the maximum frequency, try to relax the timer engine */ - if (freq < timer_main.freq) { - unsigned int new_counter = PIT_FREQ / freq; - - DISABLE(); - - for (i = 0; i < MAX_TIMERS; i++) { - if (timer_func[i].func) { - ADJUST(timer_func[i], freq); - } - } - - outportb(0x43, 0x34); - outportb(0x40, (unsigned char)new_counter); - outportb(0x40, (unsigned char)(new_counter>>8)); - timer_main.clock_ticks = 0; - timer_main.counter = new_counter; - timer_main.freq = freq; - - ENABLE(); - } + int i; + unsigned int freq = 0; + + /* are we installed? */ + if (!timer_installed) { + return -1; + } + + /* sanity check */ + if ((fid < 0) || (fid >= MAX_TIMERS) || (timer_func[fid].func == NULL)) { + return -1; + } + timer_func[fid].func = NULL; + + /* scan for maximum frequency */ + for (i = 0; i < MAX_TIMERS; i++) { + TIMER *t = &timer_func[i]; + if (t->func) { + if (freq < t->freq) { + freq = t->freq; + } + } + } + + /* if there are no callbacks left, cleanup */ + if (!freq) { + pc_remove_timer(); + return 0; + } + + /* if we just lowered the maximum frequency, try to relax the timer engine */ + if (freq < timer_main.freq) { + unsigned int new_counter = PIT_FREQ / freq; + + DISABLE(); + + for (i = 0; i < MAX_TIMERS; i++) { + if (timer_func[i].func) { + ADJUST(timer_func[i], freq); + } + } + + outportb(0x43, 0x34); + outportb(0x40, (unsigned char)new_counter); + outportb(0x40, (unsigned char)(new_counter>>8)); + timer_main.clock_ticks = 0; + timer_main.counter = new_counter; + timer_main.freq = freq; + + ENABLE(); + } - return 0; + return 0; } ENDOFUNC(pc_remove_int) - /* Desc: adjust timerfunc * * In : timerfunc id, new frequency (Hz) @@ -166,64 +165,64 @@ int pc_remove_int (int fid) * * Note: might change the main timer frequency */ -int pc_adjust_int (int fid, unsigned int freq) +int +pc_adjust_int (int fid, unsigned int freq) { - int i; - - /* are we installed? */ - if (!timer_installed) { - return -1; - } - - /* sanity check */ - if ((fid < 0) || (fid >= MAX_TIMERS) || (timer_func[fid].func == NULL)) { - return -1; - } - timer_func[fid].freq = freq; - - /* scan for maximum frequency */ - freq = 0; - for (i = 0; i < MAX_TIMERS; i++) { - TIMER *t = &timer_func[i]; - if (t->func) { - if (freq < t->freq) { - freq = t->freq; - } - } - } - - /* update main timer / sons to match highest frequency */ - DISABLE(); - - /* using '>' is correct still (and avoids updating - * the HW timer too often), but doesn't relax the timer! - */ - if (freq != timer_main.freq) { - unsigned int new_counter = PIT_FREQ / freq; - - for (i = 0; i < MAX_TIMERS; i++) { - if (timer_func[i].func) { - ADJUST(timer_func[i], freq); - } - } - - outportb(0x43, 0x34); - outportb(0x40, (unsigned char)new_counter); - outportb(0x40, (unsigned char)(new_counter>>8)); - timer_main.clock_ticks = 0; - timer_main.counter = new_counter; - timer_main.freq = freq; - } else { - ADJUST(timer_func[fid], timer_main.freq); - } - - ENABLE(); - - return 0; + int i; + + /* are we installed? */ + if (!timer_installed) { + return -1; + } + + /* sanity check */ + if ((fid < 0) || (fid >= MAX_TIMERS) || (timer_func[fid].func == NULL)) { + return -1; + } + timer_func[fid].freq = freq; + + /* scan for maximum frequency */ + freq = 0; + for (i = 0; i < MAX_TIMERS; i++) { + TIMER *t = &timer_func[i]; + if (t->func) { + if (freq < t->freq) { + freq = t->freq; + } + } + } + + /* update main timer / sons to match highest frequency */ + DISABLE(); + + /* using '>' is correct still (and avoids updating + * the HW timer too often), but doesn't relax the timer! + */ + if (freq != timer_main.freq) { + unsigned int new_counter = PIT_FREQ / freq; + + for (i = 0; i < MAX_TIMERS; i++) { + if (timer_func[i].func) { + ADJUST(timer_func[i], freq); + } + } + + outportb(0x43, 0x34); + outportb(0x40, (unsigned char)new_counter); + outportb(0x40, (unsigned char)(new_counter>>8)); + timer_main.clock_ticks = 0; + timer_main.counter = new_counter; + timer_main.freq = freq; + } else { + ADJUST(timer_func[fid], timer_main.freq); + } + + ENABLE(); + + return 0; } ENDOFUNC(pc_adjust_int) - /* Desc: install timer engine * * In : - @@ -231,36 +230,36 @@ int pc_adjust_int (int fid, unsigned int freq) * * Note: initial frequency is 18.2 Hz */ -static int install_timer (void) +static int +install_timer (void) { - if (timer_installed || pc_install_irq(TIMER_IRQ, timer)) { - return -1; - } else { - memset(timer_func, 0, sizeof(timer_func)); - - LOCKDATA(timer_func); - LOCKDATA(timer_main); - LOCKFUNC(timer); - LOCKFUNC(pc_adjust_int); - LOCKFUNC(pc_remove_int); - - timer_main.counter = 0x10000; - - DISABLE(); - outportb(0x43, 0x34); - outportb(0x40, 0); - outportb(0x40, 0); - timer_main.clock_ticks = 0; - ENABLE(); - - pc_atexit(pc_remove_timer); - timer_installed = TRUE; - return 0; - } + if (timer_installed || pc_install_irq(TIMER_IRQ, timer)) { + return -1; + } else { + memset(timer_func, 0, sizeof(timer_func)); + + LOCKDATA(timer_func); + LOCKDATA(timer_main); + LOCKFUNC(timer); + LOCKFUNC(pc_adjust_int); + LOCKFUNC(pc_remove_int); + + timer_main.counter = 0x10000; + + DISABLE(); + outportb(0x43, 0x34); + outportb(0x40, 0); + outportb(0x40, 0); + timer_main.clock_ticks = 0; + ENABLE(); + + pc_atexit(pc_remove_timer); + timer_installed = TRUE; + return 0; + } } - /* Desc: install timerfunc * * In : callback function, opaque pointer to be passed to callee, freq (Hz) @@ -268,60 +267,61 @@ static int install_timer (void) * * Note: returns -1 if error */ -int pc_install_int (PFUNC func, void *parm, unsigned int freq) +int +pc_install_int (PFUNC func, void *parm, unsigned int freq) { - int i; - TIMER *t = NULL; - - /* ensure the timer engine is set up */ - if (!timer_installed) { - if (install_timer()) { - return -1; - } - } - - /* find an empty slot */ - for (i = 0; i < MAX_TIMERS; i++) { - if (!timer_func[i].func) { - t = &timer_func[i]; - break; - } - } - if (t == NULL) { - return -1; - } - - DISABLE(); - - t->func = func; - t->parm = parm; - t->freq = freq; - t->clock_ticks = 0; - - /* update main timer / sons to match highest frequency */ - if (freq > timer_main.freq) { - unsigned int new_counter = PIT_FREQ / freq; - - for (i = 0; i < MAX_TIMERS; i++) { - if (timer_func[i].func) { - ADJUST(timer_func[i], freq); - } - } - - outportb(0x43, 0x34); - outportb(0x40, (unsigned char)new_counter); - outportb(0x40, (unsigned char)(new_counter>>8)); - timer_main.clock_ticks = 0; - timer_main.counter = new_counter; - timer_main.freq = freq; - } else { - /* t == &timer_func[i] */ - ADJUST(timer_func[i], timer_main.freq); - } - - i = t - timer_func; - - ENABLE(); - - return i; + int i; + TIMER *t = NULL; + + /* ensure the timer engine is set up */ + if (!timer_installed) { + if (install_timer()) { + return -1; + } + } + + /* find an empty slot */ + for (i = 0; i < MAX_TIMERS; i++) { + if (!timer_func[i].func) { + t = &timer_func[i]; + break; + } + } + if (t == NULL) { + return -1; + } + + DISABLE(); + + t->func = func; + t->parm = parm; + t->freq = freq; + t->clock_ticks = 0; + + /* update main timer / sons to match highest frequency */ + if (freq > timer_main.freq) { + unsigned int new_counter = PIT_FREQ / freq; + + for (i = 0; i < MAX_TIMERS; i++) { + if (timer_func[i].func) { + ADJUST(timer_func[i], freq); + } + } + + outportb(0x43, 0x34); + outportb(0x40, (unsigned char)new_counter); + outportb(0x40, (unsigned char)(new_counter>>8)); + timer_main.clock_ticks = 0; + timer_main.counter = new_counter; + timer_main.freq = freq; + } else { + /* t == &timer_func[i] */ + ADJUST(timer_func[i], timer_main.freq); + } + + i = t - timer_func; + + ENABLE(); + + return i; } diff --git a/src/glut/dos/color.c b/src/glut/dos/color.c index cfb2ff926a..c6033c2d56 100644 --- a/src/glut/dos/color.c +++ b/src/glut/dos/color.c @@ -21,7 +21,7 @@ /* * DOS/DJGPP glut driver v1.3 for Mesa * - * Copyright (C) 2002 - Borca Daniel + * Copyright (C) 2002 - Daniel Borca * Email : dborca@yahoo.com * Web : http://www.geocities.com/dborca */ @@ -31,29 +31,28 @@ #include "GL/dmesa.h" +#define CLAMP(i) ((i) > 1.0F ? 1.0F : ((i) < 0.0F ? 0.0F : (i))) -#define CLAMP(i) ((i) > 1.0 ? 1.0 : ((i) < 0.0 ? 0.0 : (i))) - - -void APIENTRY glutSetColor (int ndx, GLfloat red, GLfloat green, GLfloat blue) +void APIENTRY +glutSetColor (int ndx, GLfloat red, GLfloat green, GLfloat blue) { - if (g_display_mode & GLUT_INDEX) { - if ((ndx >= 0) && (ndx < (256 - RESERVED_COLORS))) { - DMesaSetCI(ndx, CLAMP(red), CLAMP(green), CLAMP(blue)); - } - } + if (g_display_mode & GLUT_INDEX) { + if ((ndx >= 0) && (ndx < (256 - RESERVED_COLORS))) { + DMesaSetCI(ndx, CLAMP(red), CLAMP(green), CLAMP(blue)); + } + } } - -GLfloat APIENTRY glutGetColor (int ndx, int component) +GLfloat APIENTRY +glutGetColor (int ndx, int component) { - return 0.0; + return 0.0; } - -void APIENTRY glutCopyColormap (int win) +void APIENTRY +glutCopyColormap (int win) { } diff --git a/src/glut/dos/menu.c b/src/glut/dos/menu.c index 31e05f0c47..5ca35dcfa4 100644 --- a/src/glut/dos/menu.c +++ b/src/glut/dos/menu.c @@ -21,7 +21,7 @@ /* * DOS/DJGPP glut driver v1.3 for Mesa * - * Copyright (C) 2002 - Borca Daniel + * Copyright (C) 2002 - Daniel Borca * Email : dborca@yahoo.com * Web : http://www.geocities.com/dborca */ @@ -30,87 +30,86 @@ #include "glutint.h" - GLUTmenuStatusCB g_menu_status_func = NULL; - -void APIENTRY glutMenuStateFunc (GLUTmenuStateCB func) +void APIENTRY +glutMenuStateFunc (GLUTmenuStateCB func) { - g_menu_status_func = (GLUTmenuStatusCB)func; + g_menu_status_func = (GLUTmenuStatusCB)func; } - -void APIENTRY glutMenuStatusFunc (GLUTmenuStatusCB func) +void APIENTRY +glutMenuStatusFunc (GLUTmenuStatusCB func) { - g_menu_status_func = func; + g_menu_status_func = func; } - -int APIENTRY glutCreateMenu (GLUTselectCB func) +int APIENTRY +glutCreateMenu (GLUTselectCB func) { - return 0; + return 0; } - -void APIENTRY glutDestroyMenu (int menu) +void APIENTRY +glutDestroyMenu (int menu) { } - -int APIENTRY glutGetMenu (void) +int APIENTRY +glutGetMenu (void) { - return 0; + return 0; } - -void APIENTRY glutSetMenu (int menu) +void APIENTRY +glutSetMenu (int menu) { } - -void APIENTRY glutAddMenuEntry (const char *label, int value) +void APIENTRY +glutAddMenuEntry (const char *label, int value) { } - -void APIENTRY glutAddSubMenu (const char *label, int submenu) +void APIENTRY +glutAddSubMenu (const char *label, int submenu) { } - -void APIENTRY glutChangeToMenuEntry (int item, const char *label, int value) +void APIENTRY +glutChangeToMenuEntry (int item, const char *label, int value) { } - -void APIENTRY glutChangeToSubMenu (int item, const char *label, int submenu) +void APIENTRY +glutChangeToSubMenu (int item, const char *label, int submenu) { } - -void APIENTRY glutRemoveMenuItem (int item) +void APIENTRY +glutRemoveMenuItem (int item) { } - -void APIENTRY glutAttachMenu (int button) +void APIENTRY +glutAttachMenu (int button) { } - -void APIENTRY glutDetachMenu (int button) +void APIENTRY +glutDetachMenu (int button) { } diff --git a/src/glut/dos/mouse.c b/src/glut/dos/mouse.c index 373ac49ffe..2d8a8ed53d 100644 --- a/src/glut/dos/mouse.c +++ b/src/glut/dos/mouse.c @@ -21,7 +21,7 @@ /* * DOS/DJGPP glut driver v1.3 for Mesa * - * Copyright (C) 2002 - Borca Daniel + * Copyright (C) 2002 - Daniel Borca * Email : dborca@yahoo.com * Web : http://www.geocities.com/dborca */ @@ -30,31 +30,30 @@ #include "glutint.h" - int g_mouse; int g_mouse_x = 0, g_mouse_y = 0; - -void __glutInitMouse (void) +void +__glutInitMouse (void) { - if ((g_mouse = pc_install_mouse())) { - pc_mouse_area(g_curwin->xpos, g_curwin->ypos, g_curwin->xpos + g_curwin->width - 1, g_curwin->ypos + g_curwin->height - 1); + if ((g_mouse = pc_install_mouse())) { + pc_mouse_area(g_curwin->xpos, g_curwin->ypos, g_curwin->xpos + g_curwin->width - 1, g_curwin->ypos + g_curwin->height - 1); - g_curwin->show_mouse = (g_curwin->mouse || g_curwin->motion || g_curwin->passive); - } + g_curwin->show_mouse = (g_curwin->mouse || g_curwin->motion || g_curwin->passive); + } } - -void APIENTRY glutSetCursor (int cursor) +void APIENTRY +glutSetCursor (int cursor) { - /* XXX completely futile until full mouse support (maybe never) */ + /* XXX completely futile until full mouse support (maybe never) */ } - -void APIENTRY glutWarpPointer (int x, int y) +void APIENTRY +glutWarpPointer (int x, int y) { - pc_warp_mouse(x, y); + pc_warp_mouse(x, y); } diff --git a/src/glut/dos/overlay.c b/src/glut/dos/overlay.c index b36f94c49a..11941e0b95 100644 --- a/src/glut/dos/overlay.c +++ b/src/glut/dos/overlay.c @@ -21,7 +21,7 @@ /* * DOS/DJGPP glut driver v1.3 for Mesa * - * Copyright (C) 2002 - Borca Daniel + * Copyright (C) 2002 - Daniel Borca * Email : dborca@yahoo.com * Web : http://www.geocities.com/dborca */ @@ -30,62 +30,62 @@ #include "glutint.h" - -int APIENTRY glutLayerGet (GLenum info) +int APIENTRY +glutLayerGet (GLenum info) { - switch (info) { - case GLUT_OVERLAY_POSSIBLE: - case GLUT_HAS_OVERLAY: - return GL_FALSE; - case GLUT_LAYER_IN_USE: - return GLUT_NORMAL; - case GLUT_NORMAL_DAMAGED: - return GL_FALSE; - case GLUT_OVERLAY_DAMAGED: - case GLUT_TRANSPARENT_INDEX: - default: - return -1; - } + switch (info) { + case GLUT_OVERLAY_POSSIBLE: + case GLUT_HAS_OVERLAY: + return GL_FALSE; + case GLUT_LAYER_IN_USE: + return GLUT_NORMAL; + case GLUT_NORMAL_DAMAGED: + return GL_FALSE; + case GLUT_OVERLAY_DAMAGED: + case GLUT_TRANSPARENT_INDEX: + default: + return -1; + } } - -void APIENTRY glutOverlayDisplayFunc (GLUTdisplayCB func) +void APIENTRY +glutOverlayDisplayFunc (GLUTdisplayCB func) { } - -void APIENTRY glutEstablishOverlay (void) +void APIENTRY +glutEstablishOverlay (void) { } - -void APIENTRY glutRemoveOverlay (void) +void APIENTRY +glutRemoveOverlay (void) { } - -void APIENTRY glutUseLayer (GLenum layer) +void APIENTRY +glutUseLayer (GLenum layer) { } - -void APIENTRY glutPostOverlayRedisplay (void) +void APIENTRY +glutPostOverlayRedisplay (void) { } - -void APIENTRY glutShowOverlay (void) +void APIENTRY +glutShowOverlay (void) { } - -void APIENTRY glutHideOverlay (void) +void APIENTRY +glutHideOverlay (void) { } diff --git a/src/glut/dos/util.c b/src/glut/dos/util.c index 3eec9616cf..e5969ded49 100644 --- a/src/glut/dos/util.c +++ b/src/glut/dos/util.c @@ -21,7 +21,7 @@ /* * DOS/DJGPP glut driver v1.4 for Mesa * - * Copyright (C) 2002 - Borca Daniel + * Copyright (C) 2002 - Daniel Borca * Email : dborca@yahoo.com * Web : http://www.geocities.com/dborca */ @@ -32,7 +32,6 @@ #include "glutstroke.h" - #ifdef GLUT_IMPORT_LIB extern StrokeFontRec glutStrokeRoman, glutStrokeMonoRoman; extern BitmapFontRec glutBitmap8By13, glutBitmap9By15, glutBitmapTimesRoman10, glutBitmapTimesRoman24, glutBitmapHelvetica10, glutBitmapHelvetica12, glutBitmapHelvetica18; @@ -42,30 +41,31 @@ extern BitmapFontRec glutBitmap8By13, glutBitmap9By15, glutBitmapTimesRoman10, g GLUT API constants such as GLUT_STROKE_ROMAN have to get passed through a case statement to get mapped to the actual data structure address. */ -void *__glutFont (void *font) +void * +__glutFont (void *font) { - switch ((int)font) { - case (int)GLUT_STROKE_ROMAN: - return &glutStrokeRoman; - case (int)GLUT_STROKE_MONO_ROMAN: - return &glutStrokeMonoRoman; - case (int)GLUT_BITMAP_9_BY_15: - return &glutBitmap9By15; - case (int)GLUT_BITMAP_8_BY_13: - return &glutBitmap8By13; - case (int)GLUT_BITMAP_TIMES_ROMAN_10: - return &glutBitmapTimesRoman10; - case (int)GLUT_BITMAP_TIMES_ROMAN_24: - return &glutBitmapTimesRoman24; - case (int)GLUT_BITMAP_HELVETICA_10: - return &glutBitmapHelvetica10; - case (int)GLUT_BITMAP_HELVETICA_12: - return &glutBitmapHelvetica12; - case (int)GLUT_BITMAP_HELVETICA_18: - return &glutBitmapHelvetica18; - default: /* NOTREACHED */ - __glutFatalError("bad font!"); - return NULL; - } + switch ((int)font) { + case (int)GLUT_STROKE_ROMAN: + return &glutStrokeRoman; + case (int)GLUT_STROKE_MONO_ROMAN: + return &glutStrokeMonoRoman; + case (int)GLUT_BITMAP_9_BY_15: + return &glutBitmap9By15; + case (int)GLUT_BITMAP_8_BY_13: + return &glutBitmap8By13; + case (int)GLUT_BITMAP_TIMES_ROMAN_10: + return &glutBitmapTimesRoman10; + case (int)GLUT_BITMAP_TIMES_ROMAN_24: + return &glutBitmapTimesRoman24; + case (int)GLUT_BITMAP_HELVETICA_10: + return &glutBitmapHelvetica10; + case (int)GLUT_BITMAP_HELVETICA_12: + return &glutBitmapHelvetica12; + case (int)GLUT_BITMAP_HELVETICA_18: + return &glutBitmapHelvetica18; + default: /* NOTREACHED */ + __glutFatalError("bad font!"); + return NULL; + } } #endif diff --git a/src/glut/dos/window.c b/src/glut/dos/window.c index ed95451e8d..1139f48a66 100644 --- a/src/glut/dos/window.c +++ b/src/glut/dos/window.c @@ -21,7 +21,7 @@ /* * DOS/DJGPP glut driver v1.4 for Mesa * - * Copyright (C) 2002 - Borca Daniel + * Copyright (C) 2002 - Daniel Borca * Email : dborca@users.sourceforge.net * Web : http://www.geocities.com/dborca */ @@ -33,7 +33,6 @@ #include "GL/dmesa.h" - GLUTwindow *g_curwin; static GLuint swaptime, swapcount; @@ -41,241 +40,241 @@ static DMesaVisual visual = NULL; GLUTwindow *g_windows[MAX_WINDOWS]; - -static void clean (void) +static void +clean (void) { - int i; + int i; - for (i=1; i<=MAX_WINDOWS; i++) { - glutDestroyWindow(i); - } - if (visual) DMesaDestroyVisual(visual); + for (i=1; i<=MAX_WINDOWS; i++) { + glutDestroyWindow(i); + } + if (visual) DMesaDestroyVisual(visual); - pc_close_stdout(); - pc_close_stderr(); + pc_close_stdout(); + pc_close_stderr(); } - -int APIENTRY glutCreateWindow (const char *title) +int APIENTRY +glutCreateWindow (const char *title) { - int i; - int m8width = (g_init_w + 7) & ~7; - - /* We set the Visual once. This will be our desktop (graphic mode). - * We should do this in the `glutInit' code, but we don't have any idea - * about its geometry. Supposedly, when we are about to create one - * window, we have a slight idea about resolution. - */ - if (!visual) { - if ((visual=DMesaCreateVisual(g_init_x + m8width, g_init_y + g_init_h, g_bpp, g_refresh, - g_display_mode & GLUT_DOUBLE, - !(g_display_mode & GLUT_INDEX), - (g_display_mode & GLUT_ALPHA ) ? g_alpha : 0, - (g_display_mode & GLUT_DEPTH ) ? g_depth : 0, - (g_display_mode & GLUT_STENCIL) ? g_stencil : 0, - (g_display_mode & GLUT_ACCUM ) ? g_accum : 0))==NULL) { - return 0; - } - - /* Also hook stdio/stderr once */ - pc_open_stdout(); - pc_open_stderr(); - pc_atexit(clean); - } - - /* Search for an empty slot. - * Each window has its own rendering Context and its own Buffer. - */ - for (i=0; i<MAX_WINDOWS; i++) { - if (g_windows[i] == NULL) { - DMesaContext c; - DMesaBuffer b; - GLUTwindow *w; - - if ((w = (GLUTwindow *)calloc(1, sizeof(GLUTwindow))) == NULL) { - return 0; - } - - /* Allocate the rendering Context. */ - if ((c = DMesaCreateContext(visual, NULL)) == NULL) { - free(w); - return 0; - } - - /* Allocate the Buffer (displayable area). - * We have to specify buffer size and position (inside the desktop). - */ - if ((b = DMesaCreateBuffer(visual, g_init_x, g_init_y, m8width, g_init_h)) == NULL) { - DMesaDestroyContext(c); - free(w); - return 0; - } - - /* Bind Buffer to Context and make the Context the current one. */ - if (!DMesaMakeCurrent(c, b)) { - DMesaDestroyBuffer(b); - DMesaDestroyContext(c); - free(w); - return 0; - } - - g_curwin = g_windows[i] = w; - - w->num = ++i; - w->xpos = g_init_x; - w->ypos = g_init_y; - w->width = m8width; - w->height = g_init_h; - w->context = c; - w->buffer = b; - - return i; - } - } - - return 0; + int i; + int m8width = (g_init_w + 7) & ~7; + + /* We set the Visual once. This will be our desktop (graphic mode). + * We should do this in the `glutInit' code, but we don't have any idea + * about its geometry. Supposedly, when we are about to create one + * window, we have a slight idea about resolution. + */ + if (!visual) { + if ((visual=DMesaCreateVisual(g_init_x + m8width, g_init_y + g_init_h, g_bpp, g_refresh, + g_display_mode & GLUT_DOUBLE, + !(g_display_mode & GLUT_INDEX), + (g_display_mode & GLUT_ALPHA ) ? g_alpha : 0, + (g_display_mode & GLUT_DEPTH ) ? g_depth : 0, + (g_display_mode & GLUT_STENCIL) ? g_stencil : 0, + (g_display_mode & GLUT_ACCUM ) ? g_accum : 0))==NULL) { + return 0; + } + + /* Also hook stdio/stderr once */ + pc_open_stdout(); + pc_open_stderr(); + pc_atexit(clean); + } + + /* Search for an empty slot. + * Each window has its own rendering Context and its own Buffer. + */ + for (i=0; i<MAX_WINDOWS; i++) { + if (g_windows[i] == NULL) { + DMesaContext c; + DMesaBuffer b; + GLUTwindow *w; + + if ((w = (GLUTwindow *)calloc(1, sizeof(GLUTwindow))) == NULL) { + return 0; + } + + /* Allocate the rendering Context. */ + if ((c = DMesaCreateContext(visual, NULL)) == NULL) { + free(w); + return 0; + } + + /* Allocate the Buffer (displayable area). + * We have to specify buffer size and position (inside the desktop). + */ + if ((b = DMesaCreateBuffer(visual, g_init_x, g_init_y, m8width, g_init_h)) == NULL) { + DMesaDestroyContext(c); + free(w); + return 0; + } + + /* Bind Buffer to Context and make the Context the current one. */ + if (!DMesaMakeCurrent(c, b)) { + DMesaDestroyBuffer(b); + DMesaDestroyContext(c); + free(w); + return 0; + } + + g_curwin = g_windows[i] = w; + + w->num = ++i; + w->xpos = g_init_x; + w->ypos = g_init_y; + w->width = m8width; + w->height = g_init_h; + w->context = c; + w->buffer = b; + + return i; + } + } + + return 0; } - -int APIENTRY glutCreateSubWindow (int win, int x, int y, int width, int height) +int APIENTRY +glutCreateSubWindow (int win, int x, int y, int width, int height) { - return GL_FALSE; + return GL_FALSE; } - -void APIENTRY glutDestroyWindow (int win) +void APIENTRY +glutDestroyWindow (int win) { - if (g_windows[--win]) { - GLUTwindow *w = g_windows[win]; - DMesaMakeCurrent(NULL, NULL); - DMesaDestroyBuffer(w->buffer); - DMesaDestroyContext(w->context); - free(w); - g_windows[win] = NULL; - } + if (g_windows[--win]) { + GLUTwindow *w = g_windows[win]; + DMesaMakeCurrent(NULL, NULL); + DMesaDestroyBuffer(w->buffer); + DMesaDestroyContext(w->context); + free(w); + g_windows[win] = NULL; + } } - -void APIENTRY glutPostRedisplay (void) +void APIENTRY +glutPostRedisplay (void) { - g_curwin->redisplay = GL_TRUE; + g_curwin->redisplay = GL_TRUE; } - -void APIENTRY glutSwapBuffers (void) +void APIENTRY +glutSwapBuffers (void) { - if (g_curwin->show_mouse) { - /* XXX scare mouse */ - DMesaSwapBuffers(g_curwin->buffer); - /* XXX unscare mouse */ - } else { - DMesaSwapBuffers(g_curwin->buffer); - } - - if (g_fps) { - GLint t = glutGet(GLUT_ELAPSED_TIME); - swapcount++; - if (swaptime == 0) - swaptime = t; - else if (t - swaptime > g_fps) { - double time = 0.001 * (t - swaptime); - double fps = (double)swapcount / time; - fprintf(stderr, "GLUT: %d frames in %.2f seconds = %.2f FPS\n", swapcount, time, fps); - swaptime = t; - swapcount = 0; - } - } + if (g_curwin->show_mouse) { + /* XXX scare mouse */ + DMesaSwapBuffers(g_curwin->buffer); + /* XXX unscare mouse */ + } else { + DMesaSwapBuffers(g_curwin->buffer); + } + + if (g_fps) { + GLint t = glutGet(GLUT_ELAPSED_TIME); + swapcount++; + if (swaptime == 0) + swaptime = t; + else if (t - swaptime > g_fps) { + double time = 0.001 * (t - swaptime); + double fps = (double)swapcount / time; + fprintf(stderr, "GLUT: %d frames in %.2f seconds = %.2f FPS\n", swapcount, time, fps); + swaptime = t; + swapcount = 0; + } + } } - -int APIENTRY glutGetWindow (void) +int APIENTRY +glutGetWindow (void) { - return g_curwin->num; + return g_curwin->num; } - -void APIENTRY glutSetWindow (int win) +void APIENTRY +glutSetWindow (int win) { - g_curwin = g_windows[win - 1]; - DMesaMakeCurrent(g_curwin->context, g_curwin->buffer); + g_curwin = g_windows[win - 1]; + DMesaMakeCurrent(g_curwin->context, g_curwin->buffer); } - -void APIENTRY glutSetWindowTitle (const char *title) +void APIENTRY +glutSetWindowTitle (const char *title) { } - -void APIENTRY glutSetIconTitle (const char *title) +void APIENTRY +glutSetIconTitle (const char *title) { } - -void APIENTRY glutPositionWindow (int x, int y) +void APIENTRY +glutPositionWindow (int x, int y) { - if (DMesaMoveBuffer(x, y)) { - g_curwin->xpos = x; - g_curwin->ypos = y; - } + if (DMesaMoveBuffer(x, y)) { + g_curwin->xpos = x; + g_curwin->ypos = y; + } } - -void APIENTRY glutReshapeWindow (int width, int height) +void APIENTRY +glutReshapeWindow (int width, int height) { - if (DMesaResizeBuffer(width, height)) { - g_curwin->width = width; - g_curwin->height = height; - if (g_curwin->reshape) { - g_curwin->reshape(width, height); - } else { - glViewport(0, 0, width, height); - } - } + if (DMesaResizeBuffer(width, height)) { + g_curwin->width = width; + g_curwin->height = height; + if (g_curwin->reshape) { + g_curwin->reshape(width, height); + } else { + glViewport(0, 0, width, height); + } + } } - -void APIENTRY glutFullScreen (void) +void APIENTRY +glutFullScreen (void) { } - -void APIENTRY glutPopWindow (void) +void APIENTRY +glutPopWindow (void) { } - -void APIENTRY glutPushWindow (void) +void APIENTRY +glutPushWindow (void) { } - -void APIENTRY glutIconifyWindow (void) +void APIENTRY +glutIconifyWindow (void) { } - -void APIENTRY glutShowWindow (void) +void APIENTRY +glutShowWindow (void) { } - -void APIENTRY glutHideWindow (void) +void APIENTRY +glutHideWindow (void) { } |