--- /dev/null
+# Mesa 3-D graphics library\r
+# Version: 4.0\r
+# \r
+# Copyright (C) 1999 Brian Paul All Rights Reserved.\r
+# \r
+# Permission is hereby granted, free of charge, to any person obtaining a\r
+# copy of this software and associated documentation files (the "Software"),\r
+# to deal in the Software without restriction, including without limitation\r
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+# and/or sell copies of the Software, and to permit persons to whom the\r
+# Software is furnished to do so, subject to the following conditions:\r
+# \r
+# The above copyright notice and this permission notice shall be included\r
+# in all copies or substantial portions of the Software.\r
+# \r
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r
+# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+\r
+# DOS/DJGPP glut makefile v0.1 for Mesa 4.0\r
+#\r
+# Copyright (C) 2002 - Borca Daniel\r
+# Email : dborca@yahoo.com\r
+# Web : http://www.geocities.com/dborca\r
+\r
+\r
+.PHONY: all clean\r
+\r
+TOP = ..\r
+CC = gcc\r
+CFLAGS = -I$(TOP)/include -Wall -W -Wno-unused -mcpu=pentium -ffast-math -O2\r
+AR = ar\r
+ARFLAGS = ruv\r
+LIBDIR = $(TOP)/lib\r
+\r
+GLUT_LIB = libglut.a\r
+\r
+CORE_SOURCES = \\r
+ callback.c \\r
+ color.c \\r
+ font.c \\r
+ globals.c \\r
+ init.c \\r
+ menu.c \\r
+ models.c \\r
+ overlay.c \\r
+ state.c \\r
+ teapot.c \\r
+ window.c\r
+\r
+PC_HW_OBJECTS = \\r
+ PC_HW/pc_hw.o \\r
+ PC_HW/pc_keyb.o \\r
+ PC_HW/pc_mouse.o \\r
+ PC_HW/pc_timer.o \\r
+ PC_HW/pc_irq.o\r
+\r
+SOURCES = $(CORE_SOURCES)\r
+\r
+OBJECTS = $(SOURCES:.c=.o) $(PC_HW_OBJECTS)\r
+\r
+.S.o:\r
+ gcc -o $@ -c $(CFLAGS) $<\r
+.s.o:\r
+ gcc -o $@ -c $(CFLAGS) $(<:.s=.S)\r
+.c.o:\r
+ gcc -o $@ -c $(CFLAGS) $<\r
+\r
+all: $(LIBDIR)/$(GLUT_LIB)\r
+\r
+$(LIBDIR)/$(GLUT_LIB): $(OBJECTS)\r
+ $(AR) $(ARFLAGS) $(LIBDIR)/$(GLUT_LIB) $(OBJECTS)\r
+\r
+clean:\r
+ -$(RM) *.o\r
+ -$(RM) PC_HW\*.o\r
+\r
+include depend\r
--- /dev/null
+/*\r
+ * PC/HW routine collection v0.1 for DOS/DJGPP\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include <dpmi.h>\r
+#include <fcntl.h>\r
+#include <sys/stat.h> /* for mode definitions */\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <unistd.h>\r
+\r
+#include "pc_hw.h"\r
+\r
+/*\r
+ * atexit\r
+ */\r
+#define MAX_ATEXIT 32\r
+\r
+static volatile int atexitcnt;\r
+static VFUNC atexittbl[MAX_ATEXIT];\r
+\r
+static void __attribute__((destructor)) doexit (void)\r
+{\r
+ while (atexitcnt) atexittbl[--atexitcnt]();\r
+}\r
+\r
+int pc_clexit (VFUNC f)\r
+{\r
+ int i;\r
+\r
+ for (i=0;i<atexitcnt;i++) {\r
+ if (atexittbl[i]==f) {\r
+ for (atexitcnt--;i<atexitcnt;i++) atexittbl[i] = atexittbl[i+1];\r
+ atexittbl[i] = 0;\r
+ return 0;\r
+ }\r
+ }\r
+ return -1;\r
+}\r
+\r
+int pc_atexit (VFUNC f)\r
+{\r
+ pc_clexit(f);\r
+ if (atexitcnt<MAX_ATEXIT) {\r
+ atexittbl[atexitcnt++] = f;\r
+ return 0;\r
+ }\r
+ return -1;\r
+}\r
+\r
+/*\r
+ * locked memory allocation\r
+ */\r
+void *pc_malloc (size_t size)\r
+{\r
+ void *p = malloc(size);\r
+\r
+ if (p) {\r
+ if (_go32_dpmi_lock_data(p, size)) {\r
+ free(p);\r
+ return NULL;\r
+ }\r
+ }\r
+\r
+ return p;\r
+}\r
+\r
+/*\r
+ * standard redirection\r
+ */\r
+static char errname[L_tmpnam];\r
+static char outname[L_tmpnam];\r
+\r
+static int h_out, h_outbak;\r
+static int h_err, h_errbak;\r
+\r
+void pc_open_stderr (void)\r
+{\r
+ if (tmpnam(errname)) {\r
+ h_err = open(errname, O_WRONLY |/* O_BINARY |*/ O_CREAT | O_TRUNC,\r
+ S_IREAD | S_IWRITE);\r
+ h_errbak = dup(2);\r
+ fflush(stderr);\r
+ dup2(h_err, 2);\r
+ }\r
+}\r
+\r
+void pc_close_stderr (void)\r
+{\r
+ FILE *f;\r
+ char *line = alloca(512);\r
+ \r
+ dup2(h_errbak, 2);\r
+ close(h_err);\r
+ close(h_errbak);\r
+ \r
+ if ((f=fopen(errname, "r"))!=NULL) {\r
+ while (fgets(line, 512, f)) {\r
+ fputs(line, stderr);\r
+ }\r
+ fclose(f);\r
+ }\r
+\r
+ remove(errname);\r
+}\r
+\r
+void pc_open_stdout (void)\r
+{\r
+ if (tmpnam(outname)) {\r
+ h_out = open(outname, O_WRONLY |/* O_BINARY |*/ O_CREAT | O_TRUNC,\r
+ S_IREAD | S_IWRITE);\r
+ h_outbak = dup(1);\r
+ fflush(stdout);\r
+ dup2(h_out, 1);\r
+ }\r
+}\r
+\r
+void pc_close_stdout (void)\r
+{\r
+ FILE *f;\r
+ char *line = alloca(512);\r
+ \r
+ dup2(h_outbak, 1);\r
+ close(h_out);\r
+ close(h_outbak);\r
+ \r
+ if ((f=fopen(outname, "r"))!=NULL) {\r
+ while (fgets(line, 512, f)) {\r
+ fputs(line, stdout);\r
+ }\r
+ fclose(f);\r
+ }\r
+\r
+ remove(outname);\r
+}\r
--- /dev/null
+/*\r
+ * PC/HW routine collection v0.1 for DOS/DJGPP\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#ifndef PC_HW_H_included\r
+#define PC_HW_H_included\r
+\r
+#include <dpmi.h>\r
+#include <stdlib.h>\r
+\r
+/*\r
+ * misc C definitions\r
+ */\r
+#define FALSE 0\r
+#define TRUE !FALSE\r
+\r
+#define MIN(x,y) (((x) < (y)) ? (x) : (y))\r
+#define MAX(x,y) (((x) > (y)) ? (x) : (y))\r
+#define MID(x,y,z) MAX((x), MIN((y), (z)))\r
+\r
+typedef void (*VFUNC) (void);\r
+typedef void (*PFUNC) (void *);\r
+typedef void (*MFUNC) (int x, int y, int b);\r
+\r
+/*\r
+ * atexit\r
+ */\r
+int pc_atexit (VFUNC f);\r
+int pc_clexit (VFUNC f);\r
+\r
+/*\r
+ * locked memory\r
+ */\r
+#define ENDOFUNC(x) static void x##_end() { }\r
+#define LOCKFUNC(x) _go32_dpmi_lock_code((void *)x, (long)x##_end - (long)x)\r
+#define LOCKDATA(x) _go32_dpmi_lock_data((void *)&x, sizeof(x))\r
+\r
+void *pc_malloc (size_t size);\r
+\r
+/*\r
+ * IRQ\r
+ */\r
+#define ENABLE() __asm__ __volatile__ ("sti")\r
+#define DISABLE() __asm__ __volatile__ ("cli")\r
+\r
+extern int pc_install_irq (int i, int (*handler) ());\r
+extern int pc_remove_irq (int i);\r
+\r
+/*\r
+ * keyboard\r
+ */\r
+#define KB_SHIFT_FLAG 0x0001\r
+#define KB_CTRL_FLAG 0x0002\r
+#define KB_ALT_FLAG 0x0004\r
+#define KB_LWIN_FLAG 0x0008\r
+#define KB_RWIN_FLAG 0x0010\r
+#define KB_MENU_FLAG 0x0020\r
+#define KB_SCROLOCK_FLAG 0x0100\r
+#define KB_NUMLOCK_FLAG 0x0200\r
+#define KB_CAPSLOCK_FLAG 0x0400\r
+#define KB_INALTSEQ_FLAG 0x0800\r
+#define KB_ACCENT1_FLAG 0x1000\r
+#define KB_ACCENT2_FLAG 0x2000\r
+#define KB_ACCENT3_FLAG 0x4000\r
+#define KB_ACCENT4_FLAG 0x8000\r
+\r
+#define KEY_A 1\r
+#define KEY_B 2\r
+#define KEY_C 3\r
+#define KEY_D 4\r
+#define KEY_E 5\r
+#define KEY_F 6\r
+#define KEY_G 7\r
+#define KEY_H 8\r
+#define KEY_I 9\r
+#define KEY_J 10\r
+#define KEY_K 11\r
+#define KEY_L 12\r
+#define KEY_M 13\r
+#define KEY_N 14\r
+#define KEY_O 15\r
+#define KEY_P 16\r
+#define KEY_Q 17\r
+#define KEY_R 18\r
+#define KEY_S 19\r
+#define KEY_T 20\r
+#define KEY_U 21\r
+#define KEY_V 22\r
+#define KEY_W 23\r
+#define KEY_X 24\r
+#define KEY_Y 25\r
+#define KEY_Z 26\r
+#define KEY_0 27\r
+#define KEY_1 28\r
+#define KEY_2 29\r
+#define KEY_3 30\r
+#define KEY_4 31\r
+#define KEY_5 32\r
+#define KEY_6 33\r
+#define KEY_7 34\r
+#define KEY_8 35\r
+#define KEY_9 36\r
+#define KEY_0_PAD 37\r
+#define KEY_1_PAD 38\r
+#define KEY_2_PAD 39\r
+#define KEY_3_PAD 40\r
+#define KEY_4_PAD 41\r
+#define KEY_5_PAD 42\r
+#define KEY_6_PAD 43\r
+#define KEY_7_PAD 44\r
+#define KEY_8_PAD 45\r
+#define KEY_9_PAD 46\r
+#define KEY_F1 47\r
+#define KEY_F2 48\r
+#define KEY_F3 49\r
+#define KEY_F4 50\r
+#define KEY_F5 51\r
+#define KEY_F6 52\r
+#define KEY_F7 53\r
+#define KEY_F8 54\r
+#define KEY_F9 55\r
+#define KEY_F10 56\r
+#define KEY_F11 57\r
+#define KEY_F12 58\r
+#define KEY_ESC 59\r
+#define KEY_TILDE 60\r
+#define KEY_MINUS 61\r
+#define KEY_EQUALS 62\r
+#define KEY_BACKSPACE 63\r
+#define KEY_TAB 64\r
+#define KEY_OPENBRACE 65\r
+#define KEY_CLOSEBRACE 66\r
+#define KEY_ENTER 67\r
+#define KEY_COLON 68\r
+#define KEY_QUOTE 69\r
+#define KEY_BACKSLASH 70\r
+#define KEY_BACKSLASH2 71\r
+#define KEY_COMMA 72\r
+#define KEY_STOP 73\r
+#define KEY_SLASH 74\r
+#define KEY_SPACE 75\r
+#define KEY_INSERT 76\r
+#define KEY_DEL 77\r
+#define KEY_HOME 78\r
+#define KEY_END 79\r
+#define KEY_PGUP 80\r
+#define KEY_PGDN 81\r
+#define KEY_LEFT 82\r
+#define KEY_RIGHT 83\r
+#define KEY_UP 84\r
+#define KEY_DOWN 85\r
+#define KEY_SLASH_PAD 86\r
+#define KEY_ASTERISK 87\r
+#define KEY_MINUS_PAD 88\r
+#define KEY_PLUS_PAD 89\r
+#define KEY_DEL_PAD 90\r
+#define KEY_ENTER_PAD 91\r
+#define KEY_PRTSCR 92\r
+#define KEY_PAUSE 93\r
+#define KEY_ABNT_C1 94\r
+#define KEY_YEN 95\r
+#define KEY_KANA 96\r
+#define KEY_CONVERT 97\r
+#define KEY_NOCONVERT 98\r
+#define KEY_AT 99\r
+#define KEY_CIRCUMFLEX 100\r
+#define KEY_COLON2 101\r
+#define KEY_KANJI 102\r
+\r
+#define KEY_MODIFIERS 103\r
+\r
+#define KEY_LSHIFT 103\r
+#define KEY_RSHIFT 104\r
+#define KEY_LCONTROL 105\r
+#define KEY_RCONTROL 106\r
+#define KEY_ALT 107\r
+#define KEY_ALTGR 108\r
+#define KEY_LWIN 109\r
+#define KEY_RWIN 110\r
+#define KEY_MENU 111\r
+#define KEY_SCRLOCK 112\r
+#define KEY_NUMLOCK 113\r
+#define KEY_CAPSLOCK 114\r
+\r
+#define KEY_MAX 115\r
+\r
+extern volatile char pc_key[KEY_MAX];\r
+\r
+int pc_install_keyb (void);\r
+void pc_remove_keyb (void);\r
+int pc_keypressed (void);\r
+int pc_readkey (void);\r
+\r
+/*\r
+ * timer\r
+ */\r
+int pc_install_int (PFUNC func, void *parm, unsigned int freq);\r
+void pc_remove_timer (void);\r
+\r
+/*\r
+ * mouse\r
+ */\r
+extern volatile int pc_mouse_x, pc_mouse_y, pc_mouse_b;\r
+\r
+int pc_install_mouse (void);\r
+void pc_remove_mouse (void);\r
+MFUNC pc_install_mouse_handler (MFUNC handler);\r
+void pc_mouse_area (int x1, int y1, int x2, int y2);\r
+void pc_mouse_speed (int xspeed, int yspeed);\r
+void pc_show_mouse (void);\r
+void pc_scare_mouse (void);\r
+void pc_unscare_mouse (void);\r
+\r
+/*\r
+ * standard redirection\r
+ */\r
+void pc_open_stdout (void);\r
+void pc_open_stderr (void);\r
+void pc_close_stdout (void);\r
+void pc_close_stderr (void);\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ * PC/HW routine collection v0.1 for DOS/DJGPP\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+ .file "pc_irq.S"\r
+\r
+ .text\r
+\r
+#define IRQ_STACK_SIZE 16384\r
+\r
+#define IRQ_WRAPPER_LEN (__irq_wrapper_1-__irq_wrapper_0)\r
+#define IRQ_OLD (__irq_old_0-__irq_wrapper_0)\r
+#define IRQ_HOOK (__irq_hook_0-__irq_wrapper_0)\r
+#define IRQ_STACK (__irq_stack_0-__irq_wrapper_0)\r
+\r
+ .balign 4\r
+common:\r
+ movw $0x0400, %ax\r
+ int $0x31\r
+\r
+ movl %ss:8(%ebp), %ebx\r
+ cmpl $15, %ebx\r
+ jbe 0f\r
+ fail:\r
+ orl $-1, %eax\r
+ popl %edi\r
+ popl %ebx\r
+ leave\r
+ ret\r
+\r
+ 0:\r
+ movl %ebx, %edi\r
+ imull $IRQ_WRAPPER_LEN, %edi\r
+ addl $__irq_wrapper_0, %edi\r
+\r
+ cmpb $7, %bl\r
+ jbe 1f\r
+ movb %dl, %dh\r
+ subb $8, %dh\r
+ 1:\r
+ addb %dh, %bl\r
+ ret\r
+\r
+ .balign 4\r
+ .global _pc_install_irq\r
+_pc_install_irq:\r
+ pushl %ebp\r
+ movl %esp, %ebp\r
+ pushl %ebx\r
+ pushl %edi\r
+\r
+ call common\r
+\r
+ cmpl $0, IRQ_HOOK(%edi)\r
+ jne fail\r
+\r
+ pushl $IRQ_WRAPPER_LEN\r
+ pushl %edi\r
+ call __go32_dpmi_lock_code\r
+ addl $8, %esp\r
+ testl %eax, %eax\r
+ jnz fail\r
+\r
+ pushl $IRQ_STACK_SIZE\r
+ call _pc_malloc\r
+ popl %edx\r
+ testl %eax, %eax\r
+ jz fail\r
+ addl %edx, %eax\r
+ movl %eax, IRQ_STACK(%edi)\r
+\r
+ movl %ss:12(%ebp), %eax\r
+ movl %eax, IRQ_HOOK(%edi)\r
+\r
+ movw $0x0204, %ax\r
+ int $0x31\r
+ movl %edx, IRQ_OLD(%edi)\r
+ movw %cx, IRQ_OLD+4(%edi)\r
+ movw $0x0205, %ax\r
+ movl %edi, %edx\r
+ movl %cs, %ecx\r
+ int $0x31\r
+\r
+ done:\r
+ xorl %eax, %eax\r
+ popl %edi\r
+ popl %ebx\r
+ leave\r
+ ret\r
+\r
+ .balign 4\r
+ .global _pc_remove_irq\r
+_pc_remove_irq:\r
+ pushl %ebp\r
+ movl %esp, %ebp\r
+ pushl %ebx\r
+ pushl %edi\r
+\r
+ call common\r
+\r
+ cmpl $0, IRQ_HOOK(%edi)\r
+ je fail\r
+\r
+ movl $0, IRQ_HOOK(%edi)\r
+\r
+ movw $0x0205, %ax\r
+ movl IRQ_OLD(%edi), %edx\r
+ movl IRQ_OLD+4(%edi), %ecx\r
+ int $0x31\r
+\r
+ movl IRQ_STACK(%edi), %eax\r
+ subl $IRQ_STACK_SIZE, %eax\r
+ pushl %eax\r
+ call _free\r
+ popl %eax\r
+\r
+ jmp done\r
+\r
+#define WRAPPER(x) ; \\r
+ .balign 4 ; \\r
+__irq_wrapper_##x: ; \\r
+ pushal ; \\r
+ pushl %ds ; \\r
+ pushl %es ; \\r
+ pushl %fs ; \\r
+ pushl %gs ; \\r
+ movw %ss, %bx ; \\r
+ movl %esp, %esi ; \\r
+ movl %cs:___djgpp_ds_alias, %ss ; \\r
+ movl %cs:__irq_stack_##x, %esp ; \\r
+ pushl %ss ; \\r
+ pushl %ss ; \\r
+ popl %es ; \\r
+ popl %ds ; \\r
+ movl ___djgpp_dos_sel, %fs ; \\r
+ pushl %fs ; \\r
+ popl %gs ; \\r
+ call *__irq_hook_##x ; \\r
+ movw %bx, %ss ; \\r
+ movl %esi, %esp ; \\r
+ testl %eax, %eax ; \\r
+ popl %gs ; \\r
+ popl %fs ; \\r
+ popl %es ; \\r
+ popl %ds ; \\r
+ popal ; \\r
+ jz __irq_ignore_##x ; \\r
+__irq_bypass_##x: ; \\r
+ ljmp *%cs:__irq_old_##x ; \\r
+__irq_ignore_##x: ; \\r
+ iret ; \\r
+ .balign 4 ; \\r
+__irq_old_##x: ; \\r
+ .long 0, 0 ; \\r
+__irq_hook_##x: ; \\r
+ .long 0 ; \\r
+__irq_stack_##x: ; \\r
+ .long 0\r
+\r
+ WRAPPER(0);\r
+ WRAPPER(1);\r
+ WRAPPER(2);\r
+ WRAPPER(3);\r
+ WRAPPER(4);\r
+ WRAPPER(5);\r
+ WRAPPER(6);\r
+ WRAPPER(7);\r
+ WRAPPER(8);\r
+ WRAPPER(9);\r
+ WRAPPER(10);\r
+ WRAPPER(11);\r
+ WRAPPER(12);\r
+ WRAPPER(13);\r
+ WRAPPER(14);\r
+ WRAPPER(15);\r
--- /dev/null
+/*\r
+ * PC/HW routine collection v0.1 for DOS/DJGPP\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include <pc.h>\r
+#include <sys/exceptn.h>\r
+#include <sys/farptr.h>\r
+\r
+#include "pc_hw.h"\r
+\r
+\r
+\r
+#define KEYB_IRQ 1\r
+\r
+#define KEY_BUFFER_SIZE 64\r
+\r
+#define KB_MODIFIERS (KB_SHIFT_FLAG | KB_CTRL_FLAG | KB_ALT_FLAG | KB_LWIN_FLAG | KB_RWIN_FLAG | KB_MENU_FLAG)\r
+#define KB_LED_FLAGS (KB_SCROLOCK_FLAG | KB_NUMLOCK_FLAG | KB_CAPSLOCK_FLAG)\r
+\r
+static int keyboard_installed;\r
+\r
+static volatile struct {\r
+ volatile int start, end;\r
+ volatile int key[KEY_BUFFER_SIZE];\r
+} key_buffer;\r
+\r
+static volatile int key_enhanced, key_pause_loop, key_shifts;\r
+static int leds_ok = TRUE;\r
+static int in_a_terrupt = FALSE;\r
+volatile char pc_key[KEY_MAX];\r
+\r
+\r
+\r
+/* convert Allegro format scancodes into key_shifts flag bits */\r
+static unsigned short modifier_table[KEY_MAX - KEY_MODIFIERS] =\r
+{\r
+ KB_SHIFT_FLAG, KB_SHIFT_FLAG, KB_CTRL_FLAG,\r
+ KB_CTRL_FLAG, KB_ALT_FLAG, KB_ALT_FLAG,\r
+ KB_LWIN_FLAG, KB_RWIN_FLAG, KB_MENU_FLAG,\r
+ KB_SCROLOCK_FLAG, KB_NUMLOCK_FLAG, KB_CAPSLOCK_FLAG\r
+};\r
+\r
+\r
+\r
+/* lookup table for converting hardware scancodes into Allegro format */\r
+static unsigned char hw_to_mycode[128] =\r
+{\r
+ /* 0x00 */ 0, KEY_ESC, KEY_1, KEY_2, \r
+ /* 0x04 */ KEY_3, KEY_4, KEY_5, KEY_6,\r
+ /* 0x08 */ KEY_7, KEY_8, KEY_9, KEY_0, \r
+ /* 0x0C */ KEY_MINUS, KEY_EQUALS, KEY_BACKSPACE, KEY_TAB,\r
+ /* 0x10 */ KEY_Q, KEY_W, KEY_E, KEY_R, \r
+ /* 0x14 */ KEY_T, KEY_Y, KEY_U, KEY_I,\r
+ /* 0x18 */ KEY_O, KEY_P, KEY_OPENBRACE, KEY_CLOSEBRACE, \r
+ /* 0x1C */ KEY_ENTER, KEY_LCONTROL, KEY_A, KEY_S,\r
+ /* 0x20 */ KEY_D, KEY_F, KEY_G, KEY_H, \r
+ /* 0x24 */ KEY_J, KEY_K, KEY_L, KEY_COLON,\r
+ /* 0x28 */ KEY_QUOTE, KEY_TILDE, KEY_LSHIFT, KEY_BACKSLASH, \r
+ /* 0x2C */ KEY_Z, KEY_X, KEY_C, KEY_V,\r
+ /* 0x30 */ KEY_B, KEY_N, KEY_M, KEY_COMMA, \r
+ /* 0x34 */ KEY_STOP, KEY_SLASH, KEY_RSHIFT, KEY_ASTERISK,\r
+ /* 0x38 */ KEY_ALT, KEY_SPACE, KEY_CAPSLOCK, KEY_F1, \r
+ /* 0x3C */ KEY_F2, KEY_F3, KEY_F4, KEY_F5,\r
+ /* 0x40 */ KEY_F6, KEY_F7, KEY_F8, KEY_F9, \r
+ /* 0x44 */ KEY_F10, KEY_NUMLOCK, KEY_SCRLOCK, KEY_7_PAD,\r
+ /* 0x48 */ KEY_8_PAD, KEY_9_PAD, KEY_MINUS_PAD, KEY_4_PAD, \r
+ /* 0x4C */ KEY_5_PAD, KEY_6_PAD, KEY_PLUS_PAD, KEY_1_PAD,\r
+ /* 0x50 */ KEY_2_PAD, KEY_3_PAD, KEY_0_PAD, KEY_DEL_PAD, \r
+ /* 0x54 */ KEY_PRTSCR, 0, KEY_BACKSLASH2, KEY_F11,\r
+ /* 0x58 */ KEY_F12, 0, 0, KEY_LWIN, \r
+ /* 0x5C */ KEY_RWIN, KEY_MENU, 0, 0,\r
+ /* 0x60 */ 0, 0, 0, 0, \r
+ /* 0x64 */ 0, 0, 0, 0,\r
+ /* 0x68 */ 0, 0, 0, 0, \r
+ /* 0x6C */ 0, 0, 0, 0,\r
+ /* 0x70 */ KEY_KANA, 0, 0, KEY_ABNT_C1, \r
+ /* 0x74 */ 0, 0, 0, 0,\r
+ /* 0x78 */ 0, KEY_CONVERT, 0, KEY_NOCONVERT, \r
+ /* 0x7C */ 0, KEY_YEN, 0, 0\r
+};\r
+\r
+\r
+\r
+/* lookup table for converting extended hardware codes into Allegro format */\r
+static unsigned char hw_to_mycode_ex[128] =\r
+{\r
+ /* 0x00 */ 0, KEY_ESC, KEY_1, KEY_2,\r
+ /* 0x04 */ KEY_3, KEY_4, KEY_5, KEY_6,\r
+ /* 0x08 */ KEY_7, KEY_8, KEY_9, KEY_0,\r
+ /* 0x0C */ KEY_MINUS, KEY_EQUALS, KEY_BACKSPACE, KEY_TAB,\r
+ /* 0x10 */ KEY_CIRCUMFLEX, KEY_AT, KEY_COLON2, KEY_R,\r
+ /* 0x14 */ KEY_KANJI, KEY_Y, KEY_U, KEY_I,\r
+ /* 0x18 */ KEY_O, KEY_P, KEY_OPENBRACE, KEY_CLOSEBRACE,\r
+ /* 0x1C */ KEY_ENTER_PAD, KEY_RCONTROL, KEY_A, KEY_S,\r
+ /* 0x20 */ KEY_D, KEY_F, KEY_G, KEY_H,\r
+ /* 0x24 */ KEY_J, KEY_K, KEY_L, KEY_COLON,\r
+ /* 0x28 */ KEY_QUOTE, KEY_TILDE, 0, KEY_BACKSLASH,\r
+ /* 0x2C */ KEY_Z, KEY_X, KEY_C, KEY_V,\r
+ /* 0x30 */ KEY_B, KEY_N, KEY_M, KEY_COMMA,\r
+ /* 0x34 */ KEY_STOP, KEY_SLASH_PAD, 0, KEY_PRTSCR,\r
+ /* 0x38 */ KEY_ALTGR, KEY_SPACE, KEY_CAPSLOCK, KEY_F1,\r
+ /* 0x3C */ KEY_F2, KEY_F3, KEY_F4, KEY_F5,\r
+ /* 0x40 */ KEY_F6, KEY_F7, KEY_F8, KEY_F9,\r
+ /* 0x44 */ KEY_F10, KEY_NUMLOCK, KEY_PAUSE, KEY_HOME,\r
+ /* 0x48 */ KEY_UP, KEY_PGUP, KEY_MINUS_PAD, KEY_LEFT,\r
+ /* 0x4C */ KEY_5_PAD, KEY_RIGHT, KEY_PLUS_PAD, KEY_END,\r
+ /* 0x50 */ KEY_DOWN, KEY_PGDN, KEY_INSERT, KEY_DEL,\r
+ /* 0x54 */ KEY_PRTSCR, 0, KEY_BACKSLASH2, KEY_F11,\r
+ /* 0x58 */ KEY_F12, 0, 0, KEY_LWIN,\r
+ /* 0x5C */ KEY_RWIN, KEY_MENU, 0, 0,\r
+ /* 0x60 */ 0, 0, 0, 0,\r
+ /* 0x64 */ 0, 0, 0, 0,\r
+ /* 0x68 */ 0, 0, 0, 0,\r
+ /* 0x6C */ 0, 0, 0, 0,\r
+ /* 0x70 */ 0, 0, 0, 0,\r
+ /* 0x74 */ 0, 0, 0, 0,\r
+ /* 0x78 */ 0, 0, 0, 0,\r
+ /* 0x7C */ 0, 0, 0, 0\r
+};\r
+\r
+\r
+\r
+/* default mapping table for the US keyboard layout */\r
+static unsigned short standard_key_ascii_table[KEY_MAX] =\r
+{\r
+ /* start */ 0,\r
+ /* 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',\r
+ /* numbers */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\r
+ /* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\r
+ /* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,\r
+ /* misc chars */ 27, '`', '-', '=', 8, 9, '[', ']', 13, ';', '\'', '\\', '\\', ',', '.', '/', ' ',\r
+ /* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,\r
+ /* numpad */ '/', '*', '-', '+', '.', 13,\r
+ /* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\r
+};\r
+\r
+\r
+\r
+/* capslock mapping table for the US keyboard layout */\r
+static unsigned short standard_key_capslock_table[KEY_MAX] =\r
+{\r
+ /* start */ 0,\r
+ /* 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',\r
+ /* numbers */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\r
+ /* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\r
+ /* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,\r
+ /* misc chars */ 27, '`', '-', '=', 8, 9, '[', ']', 13, ';', '\'', '\\', '\\', ',', '.', '/', ' ',\r
+ /* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,\r
+ /* numpad */ '/', '*', '-', '+', '.', 13,\r
+ /* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\r
+};\r
+\r
+\r
+\r
+/* shifted mapping table for the US keyboard layout */\r
+static unsigned short standard_key_shift_table[KEY_MAX] =\r
+{\r
+ /* start */ 0,\r
+ /* 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',\r
+ /* numbers */ ')', '!', '@', '#', '$', '%', '^', '&', '*', '(',\r
+ /* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\r
+ /* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,\r
+ /* misc chars */ 27, '~', '_', '+', 8, 9, '{', '}', 13, ':', '"', '|', '|', '<', '>', '?', ' ',\r
+ /* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,\r
+ /* numpad */ '/', '*', '-', '+', '.', 13,\r
+ /* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\r
+};\r
+\r
+\r
+\r
+/* ctrl+key mapping table for the US keyboard layout */\r
+static unsigned short standard_key_control_table[KEY_MAX] =\r
+{\r
+ /* start */ 0,\r
+ /* 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,\r
+ /* numbers */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\r
+ /* numpad */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\r
+ /* func keys */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,\r
+ /* misc chars */ 27, 2, 2, 2, 127, 127, 2, 2, 10, 2, 2, 2, 2, 2, 2, 2, 2,\r
+ /* controls */ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,\r
+ /* numpad */ 2, 2, 2, 2, 2, 10,\r
+ /* modifiers */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\r
+};\r
+\r
+\r
+\r
+/* convert numeric pad scancodes into arrow codes */\r
+static unsigned char numlock_table[10] =\r
+{\r
+ KEY_INSERT, KEY_END, KEY_DOWN, KEY_PGDN, KEY_LEFT,\r
+ KEY_5_PAD, KEY_RIGHT, KEY_HOME, KEY_UP, KEY_PGUP\r
+};\r
+\r
+\r
+\r
+/* kb_wait_for_write_ready:\r
+ * Wait for the keyboard controller to set the ready-for-write bit.\r
+ */\r
+static __inline__ int kb_wait_for_write_ready (void)\r
+{\r
+ int timeout = 4096;\r
+\r
+ while ((timeout>0) && (inportb(0x64)&2)) timeout--;\r
+\r
+ return (timeout>0);\r
+}\r
+\r
+\r
+\r
+/* kb_wait_for_read_ready:\r
+ * Wait for the keyboard controller to set the ready-for-read bit.\r
+ */\r
+static __inline__ int kb_wait_for_read_ready (void)\r
+{\r
+ int timeout = 16384;\r
+\r
+ while ((timeout>0) && (!(inportb(0x64)&1))) timeout--;\r
+\r
+ return (timeout>0);\r
+}\r
+\r
+\r
+\r
+/* kb_send_data:\r
+ * Sends a byte to the keyboard controller. Returns 1 if all OK.\r
+ */\r
+static __inline__ int kb_send_data (unsigned char data)\r
+{\r
+ int resends = 4;\r
+ int timeout, temp;\r
+\r
+ do {\r
+ if (!kb_wait_for_write_ready())\r
+ return 0;\r
+\r
+ outportb(0x60, data);\r
+ timeout = 4096;\r
+\r
+ while (--timeout>0) {\r
+ if (!kb_wait_for_read_ready())\r
+ return 0;\r
+\r
+ temp = inportb(0x60);\r
+\r
+ if (temp == 0xFA)\r
+ return 1;\r
+\r
+ if (temp == 0xFE)\r
+ break;\r
+ }\r
+ } while ((resends-- > 0) && (timeout > 0));\r
+\r
+ return 0;\r
+}\r
+\r
+\r
+\r
+static void update_leds (int leds)\r
+{\r
+ if (leds_ok) {\r
+ if (!in_a_terrupt)\r
+ DISABLE();\r
+\r
+ if (!kb_send_data(0xED)) {\r
+ kb_send_data(0xF4);\r
+ leds_ok = FALSE;\r
+ } else if (!kb_send_data((leds>>8)&7)) {\r
+ kb_send_data(0xF4);\r
+ leds_ok = FALSE;\r
+ }\r
+\r
+ if (!in_a_terrupt)\r
+ ENABLE();\r
+ }\r
+} ENDOFUNC(update_leds)\r
+\r
+\r
+\r
+static void inject_key (int scancode)\r
+{\r
+ unsigned short *table;\r
+\r
+ if ((scancode >= KEY_0_PAD) && (scancode <= KEY_9_PAD)) {\r
+ if (((key_shifts & KB_NUMLOCK_FLAG) != 0) == ((key_shifts & KB_SHIFT_FLAG) != 0)) {\r
+ scancode = numlock_table[scancode - KEY_0_PAD];\r
+ }\r
+ table = standard_key_ascii_table;\r
+ } else if (key_shifts & KB_CTRL_FLAG) {\r
+ table = standard_key_control_table;\r
+ } else if (key_shifts & KB_SHIFT_FLAG) {\r
+ if (key_shifts & KB_CAPSLOCK_FLAG) {\r
+ if (standard_key_ascii_table[scancode]==standard_key_capslock_table[scancode]) {\r
+ table = standard_key_shift_table;\r
+ } else {\r
+ table = standard_key_ascii_table;\r
+ }\r
+ } else {\r
+ table = standard_key_shift_table;\r
+ }\r
+ } else if (key_shifts & KB_CAPSLOCK_FLAG) {\r
+ table = standard_key_capslock_table;\r
+ } else {\r
+ table = standard_key_ascii_table;\r
+ }\r
+\r
+ key_buffer.key[key_buffer.end++] = (scancode<<16)|table[scancode];\r
+\r
+ if (key_buffer.end>=KEY_BUFFER_SIZE)\r
+ key_buffer.end = 0;\r
+ if (key_buffer.end==key_buffer.start) {\r
+ key_buffer.start++;\r
+ if (key_buffer.start>=KEY_BUFFER_SIZE)\r
+ key_buffer.start = 0;\r
+ }\r
+} ENDOFUNC(inject_key)\r
+\r
+static void handle_code (int scancode, int keycode)\r
+{\r
+ in_a_terrupt++;\r
+\r
+ if (keycode==0) { /* pause */\r
+ inject_key(scancode);\r
+ pc_key[KEY_PAUSE] ^= TRUE;\r
+ } else if (scancode) {\r
+ int flag;\r
+ \r
+ if (scancode>=KEY_MODIFIERS) {\r
+ flag = modifier_table[scancode - KEY_MODIFIERS];\r
+ } else {\r
+ flag = 0;\r
+ }\r
+ if ((char)keycode<0) { /* release */\r
+ pc_key[scancode] = FALSE;\r
+ if (flag&KB_MODIFIERS) {\r
+ key_shifts &= ~flag;\r
+ }\r
+ } else { /* keypress */\r
+ pc_key[scancode] = TRUE;\r
+ if (flag&KB_MODIFIERS) {\r
+ key_shifts |= flag;\r
+ }\r
+ if (flag&KB_LED_FLAGS) {\r
+ key_shifts ^= flag;\r
+ update_leds(key_shifts);\r
+ }\r
+ if (scancode<KEY_MODIFIERS) {\r
+ inject_key(scancode);\r
+ }\r
+ }\r
+ }\r
+\r
+ in_a_terrupt--;\r
+} ENDOFUNC(handle_code)\r
+\r
+static __inline__ void satisfy (void)\r
+{\r
+ __asm__("\n\\r
+ inb $0x61, %%al \n\\r
+ movb %%al, %%ah \n\\r
+ orb $0x80, %%al \n\\r
+ outb %%al, $0x61 \n\\r
+ xchgb %%al, %%ah \n\\r
+ outb %%al, $0x61 \n\\r
+ movb $0x20, %%al \n\\r
+ outb %%al, $0x20 \n\\r
+ ":::"%eax");\r
+}\r
+\r
+static int keyboard ()\r
+{\r
+ unsigned char temp, scancode;\r
+\r
+ temp = inportb(0x60);\r
+\r
+ if (temp<=0xe1) {\r
+ if (key_pause_loop) {\r
+ if (!--key_pause_loop) handle_code(KEY_PAUSE, 0);\r
+ } else\r
+ switch (temp) {\r
+ case 0xe0:\r
+ key_enhanced = TRUE;\r
+ break;\r
+ case 0xe1:\r
+ key_pause_loop = 5;\r
+ break;\r
+ default:\r
+ if (key_enhanced) {\r
+ key_enhanced = FALSE;\r
+ scancode = hw_to_mycode_ex[temp&0x7f];\r
+ } else {\r
+ scancode = hw_to_mycode[temp&0x7f];\r
+ }\r
+ handle_code(scancode, temp);\r
+ }\r
+ }\r
+\r
+ if (((temp==0x4F)||(temp==0x53))&&(key_shifts&KB_CTRL_FLAG)&&(key_shifts&KB_ALT_FLAG)) {\r
+ __asm__("\n\\r
+ movb $0x79, %%al \n\\r
+ call ___djgpp_hw_exception \n\\r
+ ":::"%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");\r
+ }\r
+\r
+ satisfy();\r
+ return 0;\r
+} ENDOFUNC(keyboard)\r
+\r
+\r
+int pc_keypressed (void)\r
+{\r
+ return (key_buffer.start!=key_buffer.end);\r
+}\r
+\r
+int pc_readkey (void)\r
+{\r
+ if (keyboard_installed) {\r
+ int key;\r
+\r
+ do {\r
+ } while (key_buffer.start==key_buffer.end);\r
+\r
+ DISABLE();\r
+ key = key_buffer.key[key_buffer.start++];\r
+ if (key_buffer.start>=KEY_BUFFER_SIZE)\r
+ key_buffer.start = 0;\r
+ ENABLE();\r
+\r
+ return key;\r
+ } else {\r
+ return 0;\r
+ }\r
+}\r
+\r
+void pc_remove_keyb (void)\r
+{\r
+ if (keyboard_installed) {\r
+ int s1, s2, s3;\r
+ \r
+ keyboard_installed = FALSE;\r
+ pc_clexit(pc_remove_keyb);\r
+\r
+ DISABLE();\r
+ _farsetsel(__djgpp_dos_sel);\r
+ _farnspokew(0x41c, _farnspeekw(0x41a));\r
+\r
+ s1 = _farnspeekb(0x417) & 0x80;\r
+ s2 = _farnspeekb(0x418) & 0xFC;\r
+ s3 = _farnspeekb(0x496) & 0xF3;\r
+\r
+ if (pc_key[KEY_RSHIFT]) { s1 |= 1; }\r
+ if (pc_key[KEY_LSHIFT]) { s1 |= 2; }\r
+ if (pc_key[KEY_LCONTROL]) { s2 |= 1; s1 |= 4; }\r
+ if (pc_key[KEY_ALT]) { s1 |= 8; s2 |= 2; }\r
+ if (pc_key[KEY_RCONTROL]) { s1 |= 4; s3 |= 4; }\r
+ if (pc_key[KEY_ALTGR]) { s1 |= 8; s3 |= 8; }\r
+\r
+ if (key_shifts&KB_SCROLOCK_FLAG) s1 |= 16;\r
+ if (key_shifts&KB_NUMLOCK_FLAG) s1 |= 32;\r
+ if (key_shifts&KB_CAPSLOCK_FLAG) s1 |= 64;\r
+\r
+ _farnspokeb(0x417, s1);\r
+ _farnspokeb(0x418, s2);\r
+ _farnspokeb(0x496, s3);\r
+ update_leds(key_shifts);\r
+\r
+ ENABLE();\r
+ pc_remove_irq(KEYB_IRQ);\r
+ }\r
+}\r
+\r
+int pc_install_keyb (void)\r
+{\r
+ if (keyboard_installed||pc_install_irq(KEYB_IRQ, keyboard)) {\r
+ return -1;\r
+ } else {\r
+ int s1, s2, s3;\r
+\r
+ LOCKDATA(key_buffer);\r
+ LOCKDATA(key_enhanced);\r
+ LOCKDATA(key_pause_loop);\r
+ LOCKDATA(key_shifts);\r
+ LOCKDATA(leds_ok);\r
+ LOCKDATA(in_a_terrupt);\r
+ LOCKDATA(pc_key);\r
+ LOCKDATA(modifier_table);\r
+ LOCKDATA(hw_to_mycode);\r
+ LOCKDATA(hw_to_mycode_ex);\r
+ LOCKDATA(standard_key_ascii_table);\r
+ LOCKDATA(standard_key_capslock_table);\r
+ LOCKDATA(standard_key_shift_table);\r
+ LOCKDATA(standard_key_control_table);\r
+ LOCKDATA(numlock_table);\r
+ LOCKFUNC(update_leds);\r
+ LOCKFUNC(inject_key);\r
+ LOCKFUNC(handle_code);\r
+ LOCKFUNC(keyboard);\r
+ \r
+ DISABLE();\r
+ _farsetsel(__djgpp_dos_sel);\r
+ _farnspokew(0x41c, _farnspeekw(0x41a));\r
+\r
+ key_shifts = 0;\r
+ s1 = _farnspeekb(0x417);\r
+ s2 = _farnspeekb(0x418);\r
+ s3 = _farnspeekb(0x496);\r
+\r
+ if (s1&1) { key_shifts |= KB_SHIFT_FLAG; pc_key[KEY_RSHIFT] = TRUE; }\r
+ if (s1&2) { key_shifts |= KB_SHIFT_FLAG; pc_key[KEY_LSHIFT] = TRUE; }\r
+ if (s2&1) { key_shifts |= KB_CTRL_FLAG; pc_key[KEY_LCONTROL] = TRUE; }\r
+ if (s2&2) { key_shifts |= KB_ALT_FLAG; pc_key[KEY_ALT] = TRUE; }\r
+ if (s3&4) { key_shifts |= KB_CTRL_FLAG; pc_key[KEY_RCONTROL] = TRUE; }\r
+ if (s3&8) { key_shifts |= KB_ALT_FLAG; pc_key[KEY_ALTGR] = TRUE; }\r
+\r
+ if (s1&16) key_shifts |= KB_SCROLOCK_FLAG;\r
+ if (s1&32) key_shifts |= KB_NUMLOCK_FLAG;\r
+ if (s1&64) key_shifts |= KB_CAPSLOCK_FLAG;\r
+ update_leds(key_shifts);\r
+\r
+ key_enhanced = key_pause_loop = 0;\r
+ key_buffer.start = key_buffer.end = 0;\r
+ ENABLE();\r
+\r
+ pc_atexit(pc_remove_keyb);\r
+ keyboard_installed = TRUE;\r
+ return 0;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * PC/HW routine collection v0.1 for DOS/DJGPP\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include <dpmi.h>\r
+\r
+#include "pc_hw.h"\r
+\r
+\r
+\r
+#define MOUSE_STACK_SIZE 16384\r
+\r
+extern void mouse_wrapper (void);\r
+extern void mouse_wrapper_end (void);\r
+\r
+static MFUNC mouse_func;\r
+static void *mouse_stack;\r
+static long mouse_callback;\r
+static __dpmi_regs mouse_regs;\r
+\r
+volatile int pc_mouse_x, pc_mouse_y, pc_mouse_b;\r
+\r
+static int minx = 0;\r
+static int maxx = 319;\r
+static int miny = 0;\r
+static int maxy = 199;\r
+\r
+static int sx = 2;\r
+static int sy = 2;\r
+\r
+static int emulat3 = FALSE;\r
+\r
+static int ox, oy;\r
+\r
+static void mouse (__dpmi_regs *r)\r
+{\r
+ int nx = (signed short)r->x.si / sx;\r
+ int ny = (signed short)r->x.di / sy;\r
+ int dx = nx - ox;\r
+ int dy = ny - oy;\r
+ ox = nx;\r
+ oy = ny;\r
+\r
+ pc_mouse_b = r->x.bx;\r
+ pc_mouse_x = MID(minx, pc_mouse_x + dx, maxx);\r
+ pc_mouse_y = MID(miny, pc_mouse_y + dy, maxy);\r
+\r
+ if (emulat3) {\r
+ if ((pc_mouse_b&3)==3) {\r
+ pc_mouse_b = 4;\r
+ }\r
+ }\r
+\r
+ if (mouse_func) {\r
+ mouse_func(pc_mouse_x, pc_mouse_y, pc_mouse_b);\r
+ }\r
+} ENDOFUNC(mouse)\r
+\r
+void pc_remove_mouse (void)\r
+{\r
+ if (mouse_callback) {\r
+ pc_clexit(pc_remove_mouse);\r
+ __asm__("\n\\r
+ movl %%edx, %%ecx \n\\r
+ shrl $16, %%ecx \n\\r
+ movw $0x0304, %%ax \n\\r
+ int $0x31 \n\\r
+ movw $0x000c, %%ax \n\\r
+ xorl %%ecx, %%ecx \n\\r
+ int $0x33 \n\\r
+ "::"d"(mouse_callback):"%eax", "%ecx");\r
+\r
+ mouse_callback = 0;\r
+\r
+ free((void *)((unsigned long)mouse_stack-MOUSE_STACK_SIZE));\r
+ }\r
+}\r
+\r
+int pc_install_mouse (void)\r
+{\r
+ int buttons;\r
+\r
+ /* fail if already call-backed */\r
+ if (mouse_callback) {\r
+ return 0;\r
+ }\r
+\r
+ /* reset mouse and get status */\r
+ __asm__("\n\\r
+ xorl %%eax, %%eax \n\\r
+ int $0x33 \n\\r
+ andl %%ebx, %%eax \n\\r
+ movl %%eax, %0 \n\\r
+ ":"=g" (buttons)::"%eax", "%ebx");\r
+ if (!buttons) {\r
+ return 0;\r
+ }\r
+\r
+ /* lock wrapper */\r
+ LOCKDATA(mouse_func);\r
+ LOCKDATA(mouse_stack);\r
+ LOCKDATA(mouse_callback);\r
+ LOCKDATA(mouse_regs);\r
+ LOCKDATA(pc_mouse_x);\r
+ LOCKDATA(pc_mouse_y);\r
+ LOCKDATA(pc_mouse_b);\r
+ LOCKDATA(minx);\r
+ LOCKDATA(maxx);\r
+ LOCKDATA(miny);\r
+ LOCKDATA(maxy);\r
+ LOCKDATA(sx);\r
+ LOCKDATA(sy);\r
+ LOCKDATA(emulat3);\r
+ LOCKDATA(ox);\r
+ LOCKDATA(oy);\r
+ LOCKFUNC(mouse);\r
+ LOCKFUNC(mouse_wrapper);\r
+\r
+ /* grab a locked stack */\r
+ if ((mouse_stack=pc_malloc(MOUSE_STACK_SIZE))==NULL) {\r
+ return 0;\r
+ }\r
+\r
+ /* try to hook a call-back */\r
+ __asm__("\n\\r
+ pushl %%ds \n\\r
+ pushl %%es \n\\r
+ movw $0x0303, %%ax \n\\r
+ pushl %%ds \n\\r
+ pushl %%cs \n\\r
+ popl %%ds \n\\r
+ popl %%es \n\\r
+ int $0x31 \n\\r
+ popl %%es \n\\r
+ popl %%ds \n\\r
+ jc 0f \n\\r
+ shll $16, %%ecx \n\\r
+ movw %%dx, %%cx \n\\r
+ movl %%ecx, %0 \n\\r
+ 0: \n\\r
+ ":"=g"(mouse_callback)\r
+ :"S" (mouse_wrapper), "D"(&mouse_regs)\r
+ :"%eax", "%ecx", "%edx");\r
+ if (!mouse_callback) {\r
+ free(mouse_stack);\r
+ return 0;\r
+ }\r
+\r
+ /* adjust stack */\r
+ mouse_stack = (void *)((unsigned long)mouse_stack + MOUSE_STACK_SIZE);\r
+\r
+ /* install the handler */\r
+ mouse_regs.x.ax = 0x000c;\r
+ mouse_regs.x.cx = 0x007f;\r
+ mouse_regs.x.dx = mouse_callback&0xffff;\r
+ mouse_regs.x.es = mouse_callback>>16;\r
+ __dpmi_int(0x33, &mouse_regs);\r
+\r
+ emulat3 = buttons<3;\r
+ pc_atexit(pc_remove_mouse);\r
+ return buttons;\r
+}\r
+\r
+MFUNC pc_install_mouse_handler (MFUNC handler)\r
+{\r
+ MFUNC old;\r
+\r
+ if (!mouse_callback && !pc_install_mouse()) {\r
+ return NULL;\r
+ }\r
+\r
+ old = mouse_func;\r
+ mouse_func = handler;\r
+ return old;\r
+}\r
+\r
+void pc_mouse_area (int x1, int y1, int x2, int y2)\r
+{\r
+ minx = x1;\r
+ maxx = x2;\r
+ miny = y1;\r
+ maxy = y2;\r
+}\r
+\r
+void pc_mouse_speed (int xspeed, int yspeed)\r
+{\r
+ DISABLE();\r
+\r
+ sx = MAX(1, xspeed);\r
+ sy = MAX(1, yspeed);\r
+\r
+ ENABLE();\r
+}\r
+\r
+void pc_show_mouse (void)\r
+{\r
+ /* not implemented */\r
+}\r
+void pc_scare_mouse (void)\r
+{\r
+ /* not implemented */\r
+}\r
+void pc_unscare_mouse (void)\r
+{\r
+ /* not implemented */\r
+}\r
+\r
+__asm__("\n\\r
+ .balign 4 \n\\r
+ .global _mouse_wrapper \n\\r
+_mouse_wrapper: \n\\r
+ cld \n\\r
+ lodsl \n\\r
+ movl %eax, %es:42(%edi) \n\\r
+ addw $4, %es:46(%edi) \n\\r
+ pushl %es \n\\r
+ movl %ss, %ebx \n\\r
+ movl %esp, %esi \n\\r
+ movl %cs:___djgpp_ds_alias, %ss \n\\r
+ movl %cs:_mouse_stack, %esp \n\\r
+ pushl %ss \n\\r
+ pushl %ss \n\\r
+ popl %es \n\\r
+ popl %ds \n\\r
+ movl ___djgpp_dos_sel, %fs \n\\r
+ pushl %fs \n\\r
+ popl %gs \n\\r
+ pushl %edi \n\\r
+ call _mouse \n\\r
+ popl %edi \n\\r
+ movl %ebx, %ss \n\\r
+ movl %esi, %esp \n\\r
+ popl %es \n\\r
+ iret \n\\r
+ \n\\r
+ .balign 4 \n\\r
+ .global _mouse_wrapper_end \n\\r
+_mouse_wrapper_end:");\r
--- /dev/null
+/*\r
+ * PC/HW routine collection v0.1 for DOS/DJGPP\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include <pc.h>\r
+\r
+#include "pc_hw.h"\r
+\r
+#define TIMER_IRQ 0\r
+\r
+#define MAX_TIMERS 8\r
+\r
+#define PIT_FREQ 0x1234DD\r
+\r
+#define unvolatile(__v, __t) __extension__ ({union { volatile __t __cp; __t __p; } __q; __q.__cp = __v; __q.__p;})\r
+\r
+static int timer_installed;\r
+\r
+typedef struct {\r
+ volatile unsigned int counter, clock_ticks, freq;\r
+ volatile PFUNC func;\r
+ volatile void *parm;\r
+} TIMER;\r
+\r
+TIMER timer_main, timer_func[MAX_TIMERS];\r
+\r
+static int timer ()\r
+{\r
+ int i;\r
+\r
+ for (i=0;i<MAX_TIMERS;i++) {\r
+ TIMER *t = &timer_func[i];\r
+ if (t->func) {\r
+ t->clock_ticks += t->counter;\r
+ if (t->clock_ticks>=timer_main.counter) {\r
+ t->clock_ticks -= timer_main.counter;\r
+ t->func(unvolatile(t->parm, void *));\r
+ }\r
+ }\r
+ }\r
+\r
+ timer_main.clock_ticks += timer_main.counter;\r
+ if (timer_main.clock_ticks>=0x10000) {\r
+ timer_main.clock_ticks -= 0x10000;\r
+ return 1;\r
+ } else {\r
+ outportb(0x20, 0x20);\r
+ return 0;\r
+ }\r
+} ENDOFUNC(timer)\r
+\r
+void pc_remove_timer (void)\r
+{\r
+ if (timer_installed) {\r
+ timer_installed = FALSE;\r
+ pc_clexit(pc_remove_timer);\r
+\r
+ DISABLE();\r
+ outportb(0x43, 0x34);\r
+ outportb(0x40, 0);\r
+ outportb(0x40, 0);\r
+ ENABLE();\r
+\r
+ pc_remove_irq(TIMER_IRQ);\r
+ }\r
+}\r
+\r
+static int install_timer (void)\r
+{\r
+ if (timer_installed||pc_install_irq(TIMER_IRQ, timer)) {\r
+ return -1;\r
+ } else {\r
+ LOCKDATA(timer_func);\r
+ LOCKDATA(timer_main);\r
+ LOCKFUNC(timer);\r
+\r
+ timer_main.counter = 0x10000;\r
+\r
+ DISABLE();\r
+ outportb(0x43, 0x34);\r
+ outportb(0x40, 0);\r
+ outportb(0x40, 0);\r
+ timer_main.clock_ticks = 0;\r
+ ENABLE();\r
+\r
+ pc_atexit(pc_remove_timer);\r
+ timer_installed = TRUE;\r
+ return 0;\r
+ }\r
+}\r
+\r
+static TIMER *find_slot (PFUNC func)\r
+{\r
+ int i;\r
+\r
+ for (i=0;i<MAX_TIMERS;i++) {\r
+ if (timer_func[i].func==func) {\r
+ return &timer_func[i];\r
+ }\r
+ }\r
+ for (i=0;i<MAX_TIMERS;i++) {\r
+ if (!timer_func[i].func) {\r
+ return &timer_func[i];\r
+ }\r
+ }\r
+\r
+ return NULL;\r
+}\r
+\r
+int pc_install_int (PFUNC func, void *parm, unsigned int freq)\r
+{\r
+ int i;\r
+ TIMER *t;\r
+\r
+ if (!timer_installed) {\r
+ if (install_timer()) {\r
+ return -1;\r
+ }\r
+ }\r
+\r
+ if ((t=find_slot(func))!=NULL) {\r
+ unsigned int new_counter = PIT_FREQ / freq;\r
+\r
+ DISABLE();\r
+\r
+ t->func = func;\r
+ t->parm = parm;\r
+ t->freq = freq;\r
+ t->clock_ticks = 0;\r
+\r
+ if (new_counter < timer_main.counter) {\r
+ for (i=0;i<MAX_TIMERS;i++) {\r
+ if (timer_func[i].func) {\r
+ timer_func[i].counter = new_counter * timer_func[i].freq / freq;\r
+ }\r
+ }\r
+ outportb(0x43, 0x34);\r
+ outportb(0x40, (unsigned char)new_counter);\r
+ outportb(0x40, (unsigned char)(new_counter>>8));\r
+ timer_main.clock_ticks = 0;\r
+ timer_main.counter = new_counter;\r
+ timer_main.freq = freq;\r
+ } else {\r
+ t->counter = PIT_FREQ * freq / (timer_main.freq * timer_main.freq);\r
+ }\r
+\r
+ ENABLE();\r
+\r
+ return 0;\r
+ }\r
+ \r
+ return -1;\r
+}\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 3.4\r
+ * Copyright (C) 1995-1998 Brian Paul\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Library General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Library General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Library General Public\r
+ * License along with this library; if not, write to the Free\r
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP glut driver v0.1 for Mesa 4.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include "GL/glut.h"\r
+#include "internal.h"\r
+\r
+\r
+void APIENTRY glutDisplayFunc (void (GLUTCALLBACK *func) (void))\r
+{\r
+ display_func = func;\r
+}\r
+\r
+\r
+void APIENTRY glutReshapeFunc (void (GLUTCALLBACK *func) (int width, int height))\r
+{\r
+ reshape_func = func;\r
+}\r
+\r
+\r
+void APIENTRY glutKeyboardFunc (void (GLUTCALLBACK *func) (unsigned char key, int x, int y))\r
+{\r
+ keyboard_func = func;\r
+}\r
+\r
+\r
+void APIENTRY glutMouseFunc (void (GLUTCALLBACK *func) (int button, int state, int x, int y))\r
+{\r
+ mouse_func = func;\r
+}\r
+\r
+\r
+void APIENTRY glutMotionFunc (void (GLUTCALLBACK *func) (int x, int y))\r
+{\r
+ motion_func = func;\r
+}\r
+\r
+\r
+void APIENTRY glutPassiveMotionFunc (void (GLUTCALLBACK *func) (int x, int y))\r
+{\r
+ passive_motion_func = func;\r
+}\r
+\r
+\r
+void APIENTRY glutEntryFunc (void (GLUTCALLBACK *func) (int state))\r
+{\r
+ entry_func = func;\r
+}\r
+\r
+\r
+void APIENTRY glutVisibilityFunc (void (GLUTCALLBACK *func) (int state))\r
+{\r
+ visibility_func = func;\r
+}\r
+\r
+\r
+void APIENTRY glutIdleFunc (void (GLUTCALLBACK *func) (void))\r
+{\r
+ idle_func = func;\r
+}\r
+\r
+\r
+void APIENTRY glutTimerFunc (unsigned int millis, void (GLUTCALLBACK *func) (int value), int value)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutMenuStateFunc (void (GLUTCALLBACK *func) (int state))\r
+{\r
+ menu_state_func = func;\r
+}\r
+\r
+\r
+void APIENTRY glutSpecialFunc (void (GLUTCALLBACK *func) (int key, int x, int y))\r
+{\r
+ special_func = func;\r
+}\r
+\r
+\r
+void APIENTRY glutSpaceballMotionFunc (void (GLUTCALLBACK *func) (int x, int y, int z))\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutSpaceballRotateFunc (void (GLUTCALLBACK *func) (int x, int y, int z))\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutSpaceballButtonFunc (void (GLUTCALLBACK *func) (int button, int state))\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutButtonBoxFunc (void (GLUTCALLBACK *func) (int button, int state))\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutDialsFunc (void (GLUTCALLBACK *func) (int dial, int value))\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutTabletMotionFunc (void (GLUTCALLBACK *func) (int x, int y))\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutTabletButtonFunc (void (GLUTCALLBACK *func) (int button, int state, int x, int y))\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutMenuStatusFunc (void (GLUTCALLBACK *func) (int status, int x, int y))\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutOverlayDisplayFunc (void (GLUTCALLBACK *func) (void))\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutWindowStatusFunc (void (GLUTCALLBACK *func) (int state))\r
+{\r
+}\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 3.4\r
+ * Copyright (C) 1995-1998 Brian Paul\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Library General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Library General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Library General Public\r
+ * License along with this library; if not, write to the Free\r
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP glut driver v0.1 for Mesa 4.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include "GL/glut.h"\r
+\r
+\r
+void APIENTRY glutSetColor (int ndx, GLfloat red, GLfloat green, GLfloat blue)\r
+{\r
+}\r
+\r
+\r
+GLfloat APIENTRY glutGetColor (int ndx, int component)\r
+{\r
+ return 0.0;\r
+}\r
+\r
+\r
+void APIENTRY glutCopyColormap (int win)\r
+{\r
+}\r
--- /dev/null
+callback.o: callback.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h\r
+color.o: color.c ../include/GL/glut.h\r
+font.o: font.c ../include/GL/glut.h\r
+globals.o: globals.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h\r
+init.o: init.c ../include/GL/glut.h internal.h PC_HW/pc_hw.h\r
+menu.o: menu.c ../include/GL/glut.h\r
+models.o: models.c ../include/GL/glut.h\r
+overlay.o: overlay.c ../include/GL/glut.h\r
+state.o: state.c ../include/GL/glut.h\r
+teapot.o: teapot.c ../include/GL/glut.h\r
+window.o: window.c ../include/GL/glut.h ../include/GL/dmesa.h internal.h \\r
+ PC_HW/pc_hw.h\r
+\r
+PC_HW/pc_hw.o: PC_HW/pc_hw.c PC_HW/pc_hw.h\r
+PC_HW/pc_keyb.o: PC_HW/pc_keyb.c PC_HW/pc_hw.h\r
+PC_HW/pc_mouse.o: PC_HW/pc_mouse.c PC_HW/pc_hw.h\r
+PC_HW/pc_timer.o: PC_HW/pc_timer.c PC_HW/pc_hw.h\r
+PC_HW/pc_irq.o: PC_HW/pc_irq.S\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 3.4\r
+ * Copyright (C) 1995-1998 Brian Paul\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Library General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Library General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Library General Public\r
+ * License along with this library; if not, write to the Free\r
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP glut driver v0.1 for Mesa 4.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include "GL/glut.h"\r
+\r
+\r
+void APIENTRY glutBitmapCharacter (void *font, int character)\r
+{\r
+}\r
+\r
+\r
+int APIENTRY glutBitmapWidth (void *font, int character)\r
+{\r
+ return 0;\r
+}\r
+\r
+\r
+void APIENTRY glutStrokeCharacter (void *font, int character)\r
+{\r
+}\r
+\r
+\r
+int APIENTRY glutStrokeWidth (void *font, int character)\r
+{\r
+ return 0;\r
+}\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 3.4\r
+ * Copyright (C) 1995-1998 Brian Paul\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Library General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Library General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Library General Public\r
+ * License along with this library; if not, write to the Free\r
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP glut driver v0.1 for Mesa 4.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include "GL/glut.h"\r
+#include "internal.h"\r
+\r
+GLenum g_display_mode = 0;\r
+GLuint g_width = DEFAULT_WIDTH;\r
+GLuint g_height = DEFAULT_HEIGHT;\r
+GLint g_mouse = GL_FALSE;\r
+GLboolean g_redisplay = GL_FALSE;\r
+GLint g_xpos = 0;\r
+GLint g_ypos = 0;\r
+\r
+void (GLUTCALLBACK *display_func) (void) = NULL;\r
+void (GLUTCALLBACK *reshape_func) (int width, int height) = NULL;\r
+void (GLUTCALLBACK *keyboard_func) (unsigned char key, int x, int y) = NULL;\r
+void (GLUTCALLBACK *mouse_func) (int button, int state, int x, int y) = NULL;\r
+void (GLUTCALLBACK *motion_func) (int x, int y) = NULL;\r
+void (GLUTCALLBACK *passive_motion_func) (int x, int y) = NULL;\r
+void (GLUTCALLBACK *entry_func) (int state) = NULL;\r
+void (GLUTCALLBACK *visibility_func) (int state) = NULL;\r
+void (GLUTCALLBACK *idle_func) (void) = NULL;\r
+void (GLUTCALLBACK *menu_state_func) (int state) = NULL;\r
+void (GLUTCALLBACK *special_func) (int key, int x, int y) = NULL;\r
+void (GLUTCALLBACK *spaceball_motion_func) (int x, int y, int z) = NULL;\r
+void (GLUTCALLBACK *spaceball_rotate_func) (int x, int y, int z) = NULL;\r
+void (GLUTCALLBACK *spaceball_button_func) (int button, int state) = NULL;\r
+void (GLUTCALLBACK *button_box_func) (int button, int state) = NULL;\r
+void (GLUTCALLBACK *dials_func) (int dial, int value) = NULL;\r
+void (GLUTCALLBACK *tablet_motion_func) (int x, int y) = NULL;\r
+void (GLUTCALLBACK *tabled_button_func) (int button, int state, int x, int y) = NULL;\r
+void (GLUTCALLBACK *menu_status_func) (int status, int x, int y) = NULL;\r
+void (GLUTCALLBACK *overlay_display_func) (void) = NULL;\r
+void (GLUTCALLBACK *window_status_func) (int state) = NULL;\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 4.0\r
+ * Copyright (C) 1995-1998 Brian Paul\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Library General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Library General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Library General Public\r
+ * License along with this library; if not, write to the Free\r
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP glut driver v0.1 for Mesa 4.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include <signal.h>\r
+#include "GL/glut.h"\r
+#include "internal.h"\r
+\r
+\r
+static void *old_sig_int = NULL;\r
+\r
+\r
+static void signal_handler (int num)\r
+{\r
+ signal(SIGINT, old_sig_int);\r
+\r
+ raise(num);\r
+}\r
+\r
+\r
+void APIENTRY glutInit (int *argcp, char **argv)\r
+{\r
+ /* Hack alert:\r
+ only SIGINT (but not Ctrl-Break)\r
+ calls the destructors and will safely clean up\r
+ */\r
+ old_sig_int = signal(SIGINT, signal_handler);\r
+}\r
+\r
+\r
+void APIENTRY glutInitDisplayMode (unsigned int mode)\r
+{\r
+ g_display_mode = mode;\r
+\r
+ pc_install_keyb();\r
+ g_mouse = pc_install_mouse();\r
+}\r
+\r
+\r
+void APIENTRY glutInitWindowPosition (int x, int y)\r
+{\r
+ g_xpos = x;\r
+ g_ypos = y;\r
+}\r
+\r
+\r
+void APIENTRY glutInitWindowSize (int width, int height)\r
+{\r
+ g_width = width;\r
+ g_height = height;\r
+}\r
+\r
+\r
+void APIENTRY glutMainLoop (void)\r
+{\r
+ GLboolean idle;\r
+ static int old_mouse_x = 0;\r
+ static int old_mouse_y = 0;\r
+ static int old_mouse_b = 0;\r
+\r
+ glutPostRedisplay();\r
+ if (reshape_func) reshape_func(g_width, g_height);\r
+ if (visibility_func) visibility_func(GLUT_VISIBLE);\r
+ if (g_mouse) pc_show_mouse();\r
+\r
+ while (GL_TRUE) {\r
+ idle = GL_TRUE;\r
+\r
+ if (g_redisplay && display_func) {\r
+ idle = GL_FALSE;\r
+ g_redisplay = GL_FALSE;\r
+\r
+ if (g_mouse && !(g_display_mode & GLUT_DOUBLE)) pc_scare_mouse();\r
+ display_func();\r
+ if (g_mouse && !(g_display_mode & GLUT_DOUBLE)) pc_unscare_mouse();\r
+ }\r
+\r
+ if (pc_keypressed()) {\r
+ int key;\r
+\r
+ idle = GL_FALSE;\r
+ key = pc_readkey();\r
+\r
+ switch (key>>16) {\r
+ case KEY_F1: if (special_func) special_func(GLUT_KEY_F1, 0, 0); break;\r
+ case KEY_F2: if (special_func) special_func(GLUT_KEY_F2, 0, 0); break;\r
+ case KEY_F3: if (special_func) special_func(GLUT_KEY_F3, 0, 0); break;\r
+ case KEY_F4: if (special_func) special_func(GLUT_KEY_F4, 0, 0); break;\r
+ case KEY_F5: if (special_func) special_func(GLUT_KEY_F5, 0, 0); break;\r
+ case KEY_F6: if (special_func) special_func(GLUT_KEY_F6, 0, 0); break;\r
+ case KEY_F7: if (special_func) special_func(GLUT_KEY_F7, 0, 0); break;\r
+ case KEY_F8: if (special_func) special_func(GLUT_KEY_F8, 0, 0); break;\r
+ case KEY_F9: if (special_func) special_func(GLUT_KEY_F9, 0, 0); break;\r
+ case KEY_F10: if (special_func) special_func(GLUT_KEY_F10, 0, 0); break;\r
+ case KEY_F11: if (special_func) special_func(GLUT_KEY_F11, 0, 0); break;\r
+ case KEY_F12: if (special_func) special_func(GLUT_KEY_F12, 0, 0); break;\r
+ case KEY_LEFT: if (special_func) special_func(GLUT_KEY_LEFT, 0, 0); break;\r
+ case KEY_UP: if (special_func) special_func(GLUT_KEY_UP, 0, 0); break;\r
+ case KEY_RIGHT: if (special_func) special_func(GLUT_KEY_RIGHT, 0, 0); break;\r
+ case KEY_DOWN: if (special_func) special_func(GLUT_KEY_DOWN, 0, 0); break;\r
+ case KEY_PGUP: if (special_func) special_func(GLUT_KEY_PAGE_UP, 0, 0); break;\r
+ case KEY_PGDN: if (special_func) special_func(GLUT_KEY_PAGE_DOWN, 0, 0); break;\r
+ case KEY_HOME: if (special_func) special_func(GLUT_KEY_HOME, 0, 0); break;\r
+ case KEY_END: if (special_func) special_func(GLUT_KEY_END, 0, 0); break;\r
+ case KEY_INSERT: if (special_func) special_func(GLUT_KEY_INSERT, 0, 0); break;\r
+ default: if (keyboard_func) keyboard_func(key & 0xFF, 0, 0);\r
+ }\r
+ }\r
+\r
+ if (g_mouse && motion_func && ((pc_mouse_x != old_mouse_x) || (pc_mouse_y != old_mouse_y))) {\r
+ idle = GL_FALSE;\r
+ old_mouse_x = pc_mouse_x;\r
+ old_mouse_y = pc_mouse_y;\r
+\r
+ motion_func(old_mouse_x, old_mouse_y);\r
+ }\r
+\r
+ if (g_mouse && mouse_func && (pc_mouse_b != old_mouse_b)) {\r
+ int new_mouse_b = pc_mouse_b;\r
+\r
+ if ((old_mouse_b & 1) && !(new_mouse_b & 1))\r
+ mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, pc_mouse_x, pc_mouse_y);\r
+ else if (!(old_mouse_b & 1) && (new_mouse_b & 1))\r
+ mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, pc_mouse_x, pc_mouse_y);\r
+\r
+ if ((old_mouse_b & 2) && !(new_mouse_b & 2))\r
+ mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, pc_mouse_x, pc_mouse_y);\r
+ else if (!(old_mouse_b & 2) && (new_mouse_b & 2))\r
+ mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, pc_mouse_x, pc_mouse_y);\r
+\r
+ if ((old_mouse_b & 4) && !(new_mouse_b & 4))\r
+ mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, pc_mouse_x, pc_mouse_y);\r
+ else if (!(old_mouse_b & 3) && (new_mouse_b & 4))\r
+ mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, pc_mouse_x, pc_mouse_y);\r
+\r
+ idle = GL_FALSE;\r
+ old_mouse_b = new_mouse_b;\r
+ }\r
+\r
+ if (idle && idle_func)\r
+ idle_func();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 4.0\r
+ * Copyright (C) 1995-1998 Brian Paul\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Library General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Library General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Library General Public\r
+ * License along with this library; if not, write to the Free\r
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP glut driver v0.1 for Mesa 4.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+ \r
+#ifndef INTERNAL_H_included\r
+#define INTERNAL_H_included\r
+\r
+\r
+#include "GL/glut.h"\r
+#include "pc_hw/pc_hw.h"\r
+\r
+\r
+#define DEFAULT_WIDTH 640\r
+#define DEFAULT_HEIGHT 480\r
+#define COLOR_DEPTH 16\r
+\r
+#define DEPTH_SIZE 16\r
+#define STENCIL_SIZE 8\r
+#define ACCUM_SIZE 16\r
+\r
+extern GLenum g_display_mode;\r
+extern GLuint g_width;\r
+extern GLuint g_height;\r
+extern GLint g_mouse;\r
+extern GLboolean g_redisplay;\r
+extern GLint g_xpos;\r
+extern GLint g_ypos;\r
+\r
+extern void (GLUTCALLBACK *display_func) (void);\r
+extern void (GLUTCALLBACK *reshape_func) (int width, int height);\r
+extern void (GLUTCALLBACK *keyboard_func) (unsigned char key, int x, int y);\r
+extern void (GLUTCALLBACK *mouse_func) (int button, int state, int x, int y);\r
+extern void (GLUTCALLBACK *motion_func) (int x, int y);\r
+extern void (GLUTCALLBACK *passive_motion_func) (int x, int y);\r
+extern void (GLUTCALLBACK *entry_func) (int state);\r
+extern void (GLUTCALLBACK *visibility_func) (int state);\r
+extern void (GLUTCALLBACK *idle_func) (void);\r
+extern void (GLUTCALLBACK *menu_state_func) (int state);\r
+extern void (GLUTCALLBACK *special_func) (int key, int x, int y);\r
+extern void (GLUTCALLBACK *spaceball_motion_func) (int x, int y, int z);\r
+extern void (GLUTCALLBACK *spaceball_rotate_func) (int x, int y, int z);\r
+extern void (GLUTCALLBACK *spaceball_button_func) (int button, int state);\r
+extern void (GLUTCALLBACK *button_box_func) (int button, int state);\r
+extern void (GLUTCALLBACK *dials_func) (int dial, int value);\r
+extern void (GLUTCALLBACK *tablet_motion_func) (int x, int y);\r
+extern void (GLUTCALLBACK *tabled_button_func) (int button, int state, int x, int y);\r
+extern void (GLUTCALLBACK *menu_status_func) (int status, int x, int y);\r
+extern void (GLUTCALLBACK *overlay_display_func) (void);\r
+extern void (GLUTCALLBACK *window_status_func) (int state);\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 3.4\r
+ * Copyright (C) 1995-1998 Brian Paul\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Library General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Library General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Library General Public\r
+ * License along with this library; if not, write to the Free\r
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP glut driver v0.1 for Mesa 4.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include "GL/glut.h"\r
+\r
+\r
+int APIENTRY glutCreateMenu (void (GLUTCALLBACK *func) (int))\r
+{\r
+ return 0;\r
+}\r
+\r
+void APIENTRY glutDestroyMenu (int menu)\r
+{\r
+}\r
+\r
+\r
+int APIENTRY glutGetMenu (void)\r
+{\r
+ return 0;\r
+}\r
+\r
+\r
+void APIENTRY glutSetMenu (int menu)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutAddMenuEntry (const char *label, int value)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutAddSubMenu (const char *label, int submenu)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutChangeToMenuEntry (int item, const char *label, int value)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutChangeToSubMenu (int item, const char *label, int submenu)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutRemoveMenuItem (int item)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutAttachMenu (int button)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutDetachMenu (int button)\r
+{\r
+}\r
--- /dev/null
+\r
+/* Copyright (c) Mark J. Kilgard, 1994, 1997. */\r
+\r
+/**\r
+(c) Copyright 1993, Silicon Graphics, Inc.\r
+\r
+ALL RIGHTS RESERVED\r
+\r
+Permission to use, copy, modify, and distribute this software\r
+for any purpose and without fee is hereby granted, provided\r
+that the above copyright notice appear in all copies and that\r
+both the copyright notice and this permission notice appear in\r
+supporting documentation, and that the name of Silicon\r
+Graphics, Inc. not be used in advertising or publicity\r
+pertaining to distribution of the software without specific,\r
+written prior permission.\r
+\r
+THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU\r
+"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR\r
+OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF\r
+MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO\r
+EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE\r
+ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR\r
+CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,\r
+INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,\r
+SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR\r
+NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY\r
+OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
+ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR\r
+PERFORMANCE OF THIS SOFTWARE.\r
+\r
+US Government Users Restricted Rights\r
+\r
+Use, duplication, or disclosure by the Government is subject to\r
+restrictions set forth in FAR 52.227.19(c)(2) or subparagraph\r
+(c)(1)(ii) of the Rights in Technical Data and Computer\r
+Software clause at DFARS 252.227-7013 and/or in similar or\r
+successor clauses in the FAR or the DOD or NASA FAR\r
+Supplement. Unpublished-- rights reserved under the copyright\r
+laws of the United States. Contractor/manufacturer is Silicon\r
+Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA\r
+94039-7311.\r
+\r
+OpenGL(TM) is a trademark of Silicon Graphics, Inc.\r
+*/\r
+\r
+#include <math.h>\r
+#include <GL/gl.h>\r
+#include <GL/glu.h>\r
+#include "GL/glut.h"\r
+\r
+/* Some <math.h> files do not define M_PI... */\r
+#ifndef M_PI\r
+#define M_PI 3.14159265358979323846\r
+#endif\r
+\r
+static GLUquadricObj *quadObj;\r
+\r
+#define QUAD_OBJ_INIT() { if(!quadObj) initQuadObj(); }\r
+\r
+static void\r
+initQuadObj(void)\r
+{\r
+ quadObj = gluNewQuadric();\r
+/* if (!quadObj)\r
+ __glutFatalError("out of memory."); */\r
+}\r
+\r
+/* CENTRY */\r
+void APIENTRY\r
+glutWireSphere(GLdouble radius, GLint slices, GLint stacks)\r
+{\r
+ QUAD_OBJ_INIT();\r
+ gluQuadricDrawStyle(quadObj, GLU_LINE);\r
+ gluQuadricNormals(quadObj, GLU_SMOOTH);\r
+ /* If we ever changed/used the texture or orientation state\r
+ of quadObj, we'd need to change it to the defaults here\r
+ with gluQuadricTexture and/or gluQuadricOrientation. */\r
+ gluSphere(quadObj, radius, slices, stacks);\r
+}\r
+\r
+void APIENTRY\r
+glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)\r
+{\r
+ QUAD_OBJ_INIT();\r
+ gluQuadricDrawStyle(quadObj, GLU_FILL);\r
+ gluQuadricNormals(quadObj, GLU_SMOOTH);\r
+ /* If we ever changed/used the texture or orientation state\r
+ of quadObj, we'd need to change it to the defaults here\r
+ with gluQuadricTexture and/or gluQuadricOrientation. */\r
+ gluSphere(quadObj, radius, slices, stacks);\r
+}\r
+\r
+void APIENTRY\r
+glutWireCone(GLdouble base, GLdouble height,\r
+ GLint slices, GLint stacks)\r
+{\r
+ QUAD_OBJ_INIT();\r
+ gluQuadricDrawStyle(quadObj, GLU_LINE);\r
+ gluQuadricNormals(quadObj, GLU_SMOOTH);\r
+ /* If we ever changed/used the texture or orientation state\r
+ of quadObj, we'd need to change it to the defaults here\r
+ with gluQuadricTexture and/or gluQuadricOrientation. */\r
+ gluCylinder(quadObj, base, 0.0, height, slices, stacks);\r
+}\r
+\r
+void APIENTRY\r
+glutSolidCone(GLdouble base, GLdouble height,\r
+ GLint slices, GLint stacks)\r
+{\r
+ QUAD_OBJ_INIT();\r
+ gluQuadricDrawStyle(quadObj, GLU_FILL);\r
+ gluQuadricNormals(quadObj, GLU_SMOOTH);\r
+ /* If we ever changed/used the texture or orientation state\r
+ of quadObj, we'd need to change it to the defaults here\r
+ with gluQuadricTexture and/or gluQuadricOrientation. */\r
+ gluCylinder(quadObj, base, 0.0, height, slices, stacks);\r
+}\r
+\r
+/* ENDCENTRY */\r
+\r
+static void\r
+drawBox(GLfloat size, GLenum type)\r
+{\r
+ static GLfloat n[6][3] =\r
+ {\r
+ {-1.0, 0.0, 0.0},\r
+ {0.0, 1.0, 0.0},\r
+ {1.0, 0.0, 0.0},\r
+ {0.0, -1.0, 0.0},\r
+ {0.0, 0.0, 1.0},\r
+ {0.0, 0.0, -1.0}\r
+ };\r
+ static GLint faces[6][4] =\r
+ {\r
+ {0, 1, 2, 3},\r
+ {3, 2, 6, 7},\r
+ {7, 6, 5, 4},\r
+ {4, 5, 1, 0},\r
+ {5, 6, 2, 1},\r
+ {7, 4, 0, 3}\r
+ };\r
+ GLfloat v[8][3];\r
+ GLint i;\r
+\r
+ v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2;\r
+ v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2;\r
+ v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2;\r
+ v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2;\r
+ v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2;\r
+ v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;\r
+\r
+ for (i = 5; i >= 0; i--) {\r
+ glBegin(type);\r
+ glNormal3fv(&n[i][0]);\r
+ glVertex3fv(&v[faces[i][0]][0]);\r
+ glVertex3fv(&v[faces[i][1]][0]);\r
+ glVertex3fv(&v[faces[i][2]][0]);\r
+ glVertex3fv(&v[faces[i][3]][0]);\r
+ glEnd();\r
+ }\r
+}\r
+\r
+/* CENTRY */\r
+void APIENTRY\r
+glutWireCube(GLdouble size)\r
+{\r
+ drawBox(size, GL_LINE_LOOP);\r
+}\r
+\r
+void APIENTRY\r
+glutSolidCube(GLdouble size)\r
+{\r
+ drawBox(size, GL_QUADS);\r
+}\r
+\r
+/* ENDCENTRY */\r
+\r
+static void\r
+doughnut(GLfloat r, GLfloat R, GLint nsides, GLint rings)\r
+{\r
+ int i, j;\r
+ GLfloat theta, phi, theta1;\r
+ GLfloat cosTheta, sinTheta;\r
+ GLfloat cosTheta1, sinTheta1;\r
+ GLfloat ringDelta, sideDelta;\r
+\r
+ ringDelta = 2.0 * M_PI / rings;\r
+ sideDelta = 2.0 * M_PI / nsides;\r
+\r
+ theta = 0.0;\r
+ cosTheta = 1.0;\r
+ sinTheta = 0.0;\r
+ for (i = rings - 1; i >= 0; i--) {\r
+ theta1 = theta + ringDelta;\r
+ cosTheta1 = cos(theta1);\r
+ sinTheta1 = sin(theta1);\r
+ glBegin(GL_QUAD_STRIP);\r
+ phi = 0.0;\r
+ for (j = nsides; j >= 0; j--) {\r
+ GLfloat cosPhi, sinPhi, dist;\r
+\r
+ phi += sideDelta;\r
+ cosPhi = cos(phi);\r
+ sinPhi = sin(phi);\r
+ dist = R + r * cosPhi;\r
+\r
+ glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);\r
+ glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);\r
+ glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);\r
+ glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);\r
+ }\r
+ glEnd();\r
+ theta = theta1;\r
+ cosTheta = cosTheta1;\r
+ sinTheta = sinTheta1;\r
+ }\r
+}\r
+\r
+/* CENTRY */\r
+void APIENTRY\r
+glutWireTorus(GLdouble innerRadius, GLdouble outerRadius,\r
+ GLint nsides, GLint rings)\r
+{\r
+ glPushAttrib(GL_POLYGON_BIT);\r
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);\r
+ doughnut(innerRadius, outerRadius, nsides, rings);\r
+ glPopAttrib();\r
+}\r
+\r
+void APIENTRY\r
+glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius,\r
+ GLint nsides, GLint rings)\r
+{\r
+ doughnut(innerRadius, outerRadius, nsides, rings);\r
+}\r
+\r
+/* ENDCENTRY */\r
+\r
+static GLfloat dodec[20][3];\r
+\r
+static void\r
+initDodecahedron(void)\r
+{\r
+ GLfloat alpha, beta;\r
+\r
+ alpha = sqrt(2.0 / (3.0 + sqrt(5.0)));\r
+ beta = 1.0 + sqrt(6.0 / (3.0 + sqrt(5.0)) -\r
+ 2.0 + 2.0 * sqrt(2.0 / (3.0 + sqrt(5.0))));\r
+ /* *INDENT-OFF* */\r
+ dodec[0][0] = -alpha; dodec[0][1] = 0; dodec[0][2] = beta;\r
+ dodec[1][0] = alpha; dodec[1][1] = 0; dodec[1][2] = beta;\r
+ dodec[2][0] = -1; dodec[2][1] = -1; dodec[2][2] = -1;\r
+ dodec[3][0] = -1; dodec[3][1] = -1; dodec[3][2] = 1;\r
+ dodec[4][0] = -1; dodec[4][1] = 1; dodec[4][2] = -1;\r
+ dodec[5][0] = -1; dodec[5][1] = 1; dodec[5][2] = 1;\r
+ dodec[6][0] = 1; dodec[6][1] = -1; dodec[6][2] = -1;\r
+ dodec[7][0] = 1; dodec[7][1] = -1; dodec[7][2] = 1;\r
+ dodec[8][0] = 1; dodec[8][1] = 1; dodec[8][2] = -1;\r
+ dodec[9][0] = 1; dodec[9][1] = 1; dodec[9][2] = 1;\r
+ dodec[10][0] = beta; dodec[10][1] = alpha; dodec[10][2] = 0;\r
+ dodec[11][0] = beta; dodec[11][1] = -alpha; dodec[11][2] = 0;\r
+ dodec[12][0] = -beta; dodec[12][1] = alpha; dodec[12][2] = 0;\r
+ dodec[13][0] = -beta; dodec[13][1] = -alpha; dodec[13][2] = 0;\r
+ dodec[14][0] = -alpha; dodec[14][1] = 0; dodec[14][2] = -beta;\r
+ dodec[15][0] = alpha; dodec[15][1] = 0; dodec[15][2] = -beta;\r
+ dodec[16][0] = 0; dodec[16][1] = beta; dodec[16][2] = alpha;\r
+ dodec[17][0] = 0; dodec[17][1] = beta; dodec[17][2] = -alpha;\r
+ dodec[18][0] = 0; dodec[18][1] = -beta; dodec[18][2] = alpha;\r
+ dodec[19][0] = 0; dodec[19][1] = -beta; dodec[19][2] = -alpha;\r
+ /* *INDENT-ON* */\r
+\r
+}\r
+\r
+#define DIFF3(_a,_b,_c) { \\r
+ (_c)[0] = (_a)[0] - (_b)[0]; \\r
+ (_c)[1] = (_a)[1] - (_b)[1]; \\r
+ (_c)[2] = (_a)[2] - (_b)[2]; \\r
+}\r
+\r
+static void\r
+crossprod(GLfloat v1[3], GLfloat v2[3], GLfloat prod[3])\r
+{\r
+ GLfloat p[3]; /* in case prod == v1 or v2 */\r
+\r
+ p[0] = v1[1] * v2[2] - v2[1] * v1[2];\r
+ p[1] = v1[2] * v2[0] - v2[2] * v1[0];\r
+ p[2] = v1[0] * v2[1] - v2[0] * v1[1];\r
+ prod[0] = p[0];\r
+ prod[1] = p[1];\r
+ prod[2] = p[2];\r
+}\r
+\r
+static void\r
+normalize(GLfloat v[3])\r
+{\r
+ GLfloat d;\r
+\r
+ d = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);\r
+ if (d == 0.0) {\r
+// __glutWarning("normalize: zero length vector");\r
+ v[0] = d = 1.0;\r
+ }\r
+ d = 1 / d;\r
+ v[0] *= d;\r
+ v[1] *= d;\r
+ v[2] *= d;\r
+}\r
+\r
+static void\r
+pentagon(int a, int b, int c, int d, int e, GLenum shadeType)\r
+{\r
+ GLfloat n0[3], d1[3], d2[3];\r
+\r
+ DIFF3(dodec[a], dodec[b], d1);\r
+ DIFF3(dodec[b], dodec[c], d2);\r
+ crossprod(d1, d2, n0);\r
+ normalize(n0);\r
+\r
+ glBegin(shadeType);\r
+ glNormal3fv(n0);\r
+ glVertex3fv(&dodec[a][0]);\r
+ glVertex3fv(&dodec[b][0]);\r
+ glVertex3fv(&dodec[c][0]);\r
+ glVertex3fv(&dodec[d][0]);\r
+ glVertex3fv(&dodec[e][0]);\r
+ glEnd();\r
+}\r
+\r
+static void\r
+dodecahedron(GLenum type)\r
+{\r
+ static int inited = 0;\r
+\r
+ if (inited == 0) {\r
+ inited = 1;\r
+ initDodecahedron();\r
+ }\r
+ pentagon(0, 1, 9, 16, 5, type);\r
+ pentagon(1, 0, 3, 18, 7, type);\r
+ pentagon(1, 7, 11, 10, 9, type);\r
+ pentagon(11, 7, 18, 19, 6, type);\r
+ pentagon(8, 17, 16, 9, 10, type);\r
+ pentagon(2, 14, 15, 6, 19, type);\r
+ pentagon(2, 13, 12, 4, 14, type);\r
+ pentagon(2, 19, 18, 3, 13, type);\r
+ pentagon(3, 0, 5, 12, 13, type);\r
+ pentagon(6, 15, 8, 10, 11, type);\r
+ pentagon(4, 17, 8, 15, 14, type);\r
+ pentagon(4, 12, 5, 16, 17, type);\r
+}\r
+\r
+/* CENTRY */\r
+void APIENTRY\r
+glutWireDodecahedron(void)\r
+{\r
+ dodecahedron(GL_LINE_LOOP);\r
+}\r
+\r
+void APIENTRY\r
+glutSolidDodecahedron(void)\r
+{\r
+ dodecahedron(GL_TRIANGLE_FAN);\r
+}\r
+\r
+/* ENDCENTRY */\r
+\r
+static void\r
+recorditem(GLfloat * n1, GLfloat * n2, GLfloat * n3,\r
+ GLenum shadeType)\r
+{\r
+ GLfloat q0[3], q1[3];\r
+\r
+ DIFF3(n1, n2, q0);\r
+ DIFF3(n2, n3, q1);\r
+ crossprod(q0, q1, q1);\r
+ normalize(q1);\r
+\r
+ glBegin(shadeType);\r
+ glNormal3fv(q1);\r
+ glVertex3fv(n1);\r
+ glVertex3fv(n2);\r
+ glVertex3fv(n3);\r
+ glEnd();\r
+}\r
+\r
+static void\r
+subdivide(GLfloat * v0, GLfloat * v1, GLfloat * v2,\r
+ GLenum shadeType)\r
+{\r
+ int depth;\r
+ GLfloat w0[3], w1[3], w2[3];\r
+ GLfloat l;\r
+ int i, j, k, n;\r
+\r
+ depth = 1;\r
+ for (i = 0; i < depth; i++) {\r
+ for (j = 0; i + j < depth; j++) {\r
+ k = depth - i - j;\r
+ for (n = 0; n < 3; n++) {\r
+ w0[n] = (i * v0[n] + j * v1[n] + k * v2[n]) / depth;\r
+ w1[n] = ((i + 1) * v0[n] + j * v1[n] + (k - 1) * v2[n])\r
+ / depth;\r
+ w2[n] = (i * v0[n] + (j + 1) * v1[n] + (k - 1) * v2[n])\r
+ / depth;\r
+ }\r
+ l = sqrt(w0[0] * w0[0] + w0[1] * w0[1] + w0[2] * w0[2]);\r
+ w0[0] /= l;\r
+ w0[1] /= l;\r
+ w0[2] /= l;\r
+ l = sqrt(w1[0] * w1[0] + w1[1] * w1[1] + w1[2] * w1[2]);\r
+ w1[0] /= l;\r
+ w1[1] /= l;\r
+ w1[2] /= l;\r
+ l = sqrt(w2[0] * w2[0] + w2[1] * w2[1] + w2[2] * w2[2]);\r
+ w2[0] /= l;\r
+ w2[1] /= l;\r
+ w2[2] /= l;\r
+ recorditem(w1, w0, w2, shadeType);\r
+ }\r
+ }\r
+}\r
+\r
+static void\r
+drawtriangle(int i, GLfloat data[][3], int ndx[][3],\r
+ GLenum shadeType)\r
+{\r
+ GLfloat *x0, *x1, *x2;\r
+\r
+ x0 = data[ndx[i][0]];\r
+ x1 = data[ndx[i][1]];\r
+ x2 = data[ndx[i][2]];\r
+ subdivide(x0, x1, x2, shadeType);\r
+}\r
+\r
+/* octahedron data: The octahedron produced is centered at the\r
+ origin and has radius 1.0 */\r
+static GLfloat odata[6][3] =\r
+{\r
+ {1.0, 0.0, 0.0},\r
+ {-1.0, 0.0, 0.0},\r
+ {0.0, 1.0, 0.0},\r
+ {0.0, -1.0, 0.0},\r
+ {0.0, 0.0, 1.0},\r
+ {0.0, 0.0, -1.0}\r
+};\r
+\r
+static int ondex[8][3] =\r
+{\r
+ {0, 4, 2},\r
+ {1, 2, 4},\r
+ {0, 3, 4},\r
+ {1, 4, 3},\r
+ {0, 2, 5},\r
+ {1, 5, 2},\r
+ {0, 5, 3},\r
+ {1, 3, 5}\r
+};\r
+\r
+static void\r
+octahedron(GLenum shadeType)\r
+{\r
+ int i;\r
+\r
+ for (i = 7; i >= 0; i--) {\r
+ drawtriangle(i, odata, ondex, shadeType);\r
+ }\r
+}\r
+\r
+/* CENTRY */\r
+void APIENTRY\r
+glutWireOctahedron(void)\r
+{\r
+ octahedron(GL_LINE_LOOP);\r
+}\r
+\r
+void APIENTRY\r
+glutSolidOctahedron(void)\r
+{\r
+ octahedron(GL_TRIANGLES);\r
+}\r
+\r
+/* ENDCENTRY */\r
+\r
+/* icosahedron data: These numbers are rigged to make an\r
+ icosahedron of radius 1.0 */\r
+\r
+#define X .525731112119133606\r
+#define Z .850650808352039932\r
+\r
+static GLfloat idata[12][3] =\r
+{\r
+ {-X, 0, Z},\r
+ {X, 0, Z},\r
+ {-X, 0, -Z},\r
+ {X, 0, -Z},\r
+ {0, Z, X},\r
+ {0, Z, -X},\r
+ {0, -Z, X},\r
+ {0, -Z, -X},\r
+ {Z, X, 0},\r
+ {-Z, X, 0},\r
+ {Z, -X, 0},\r
+ {-Z, -X, 0}\r
+};\r
+\r
+static int index[20][3] =\r
+{\r
+ {0, 4, 1},\r
+ {0, 9, 4},\r
+ {9, 5, 4},\r
+ {4, 5, 8},\r
+ {4, 8, 1},\r
+ {8, 10, 1},\r
+ {8, 3, 10},\r
+ {5, 3, 8},\r
+ {5, 2, 3},\r
+ {2, 7, 3},\r
+ {7, 10, 3},\r
+ {7, 6, 10},\r
+ {7, 11, 6},\r
+ {11, 0, 6},\r
+ {0, 1, 6},\r
+ {6, 1, 10},\r
+ {9, 0, 11},\r
+ {9, 11, 2},\r
+ {9, 2, 5},\r
+ {7, 2, 11},\r
+};\r
+\r
+static void\r
+icosahedron(GLenum shadeType)\r
+{\r
+ int i;\r
+\r
+ for (i = 19; i >= 0; i--) {\r
+ drawtriangle(i, idata, index, shadeType);\r
+ }\r
+}\r
+\r
+/* CENTRY */\r
+void APIENTRY\r
+glutWireIcosahedron(void)\r
+{\r
+ icosahedron(GL_LINE_LOOP);\r
+}\r
+\r
+void APIENTRY\r
+glutSolidIcosahedron(void)\r
+{\r
+ icosahedron(GL_TRIANGLES);\r
+}\r
+\r
+/* ENDCENTRY */\r
+\r
+/* tetrahedron data: */\r
+\r
+#define T 1.73205080756887729\r
+\r
+static GLfloat tdata[4][3] =\r
+{\r
+ {T, T, T},\r
+ {T, -T, -T},\r
+ {-T, T, -T},\r
+ {-T, -T, T}\r
+};\r
+\r
+static int tndex[4][3] =\r
+{\r
+ {0, 1, 3},\r
+ {2, 1, 0},\r
+ {3, 2, 0},\r
+ {1, 2, 3}\r
+};\r
+\r
+static void\r
+tetrahedron(GLenum shadeType)\r
+{\r
+ int i;\r
+\r
+ for (i = 3; i >= 0; i--)\r
+ drawtriangle(i, tdata, tndex, shadeType);\r
+}\r
+\r
+/* CENTRY */\r
+void APIENTRY\r
+glutWireTetrahedron(void)\r
+{\r
+ tetrahedron(GL_LINE_LOOP);\r
+}\r
+\r
+void APIENTRY\r
+glutSolidTetrahedron(void)\r
+{\r
+ tetrahedron(GL_TRIANGLES);\r
+}\r
+\r
+/* ENDCENTRY */\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 3.4\r
+ * Copyright (C) 1995-1998 Brian Paul\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Library General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Library General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Library General Public\r
+ * License along with this library; if not, write to the Free\r
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP glut driver v0.1 for Mesa 4.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include "GL/glut.h"\r
+\r
+\r
+void APIENTRY glutEstablishOverlay (void)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutRemoveOverlay (void)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutUseLayer (GLenum layer)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutPostOverlayRedisplay (void)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutShowOverlay (void)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutHideOverlay (void)\r
+{\r
+}\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 3.4\r
+ * Copyright (C) 1995-1998 Brian Paul\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Library General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Library General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Library General Public\r
+ * License along with this library; if not, write to the Free\r
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP glut driver v0.1 for Mesa 4.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include "GL/glut.h"\r
+\r
+\r
+int APIENTRY glutGet (GLenum type)\r
+{\r
+ switch (type) {\r
+ case GLUT_WINDOW_RGBA:\r
+ return 1;\r
+ default:\r
+ return 0;\r
+ }\r
+}\r
+\r
+\r
+int APIENTRY glutDeviceGet (GLenum type)\r
+{\r
+ return 0;\r
+}\r
--- /dev/null
+\r
+/* Copyright (c) Mark J. Kilgard, 1994. */\r
+\r
+/**\r
+(c) Copyright 1993, Silicon Graphics, Inc.\r
+\r
+ALL RIGHTS RESERVED\r
+\r
+Permission to use, copy, modify, and distribute this software\r
+for any purpose and without fee is hereby granted, provided\r
+that the above copyright notice appear in all copies and that\r
+both the copyright notice and this permission notice appear in\r
+supporting documentation, and that the name of Silicon\r
+Graphics, Inc. not be used in advertising or publicity\r
+pertaining to distribution of the software without specific,\r
+written prior permission.\r
+\r
+THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU\r
+"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR\r
+OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF\r
+MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO\r
+EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE\r
+ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR\r
+CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,\r
+INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,\r
+SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR\r
+NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY\r
+OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
+ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR\r
+PERFORMANCE OF THIS SOFTWARE.\r
+\r
+US Government Users Restricted Rights\r
+\r
+Use, duplication, or disclosure by the Government is subject to\r
+restrictions set forth in FAR 52.227.19(c)(2) or subparagraph\r
+(c)(1)(ii) of the Rights in Technical Data and Computer\r
+Software clause at DFARS 252.227-7013 and/or in similar or\r
+successor clauses in the FAR or the DOD or NASA FAR\r
+Supplement. Unpublished-- rights reserved under the copyright\r
+laws of the United States. Contractor/manufacturer is Silicon\r
+Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA\r
+94039-7311.\r
+\r
+OpenGL(TM) is a trademark of Silicon Graphics, Inc.\r
+*/\r
+\r
+#include <GL/gl.h>\r
+#include <GL/glu.h>\r
+#include "GL/glut.h"\r
+\r
+/* Rim, body, lid, and bottom data must be reflected in x and\r
+ y; handle and spout data across the y axis only. */\r
+\r
+static int patchdata[][16] =\r
+{\r
+ /* rim */\r
+ {102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11,\r
+ 12, 13, 14, 15},\r
+ /* body */\r
+ {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,\r
+ 24, 25, 26, 27},\r
+ {24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36,\r
+ 37, 38, 39, 40},\r
+ /* lid */\r
+ {96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101,\r
+ 101, 0, 1, 2, 3,},\r
+ {0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112,\r
+ 113, 114, 115, 116, 117},\r
+ /* bottom */\r
+ {118, 118, 118, 118, 124, 122, 119, 121, 123, 126,\r
+ 125, 120, 40, 39, 38, 37},\r
+ /* handle */\r
+ {41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,\r
+ 53, 54, 55, 56},\r
+ {53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,\r
+ 28, 65, 66, 67},\r
+ /* spout */\r
+ {68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,\r
+ 80, 81, 82, 83},\r
+ {80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,\r
+ 92, 93, 94, 95}\r
+};\r
+/* *INDENT-OFF* */\r
+\r
+static float cpdata[][3] =\r
+{\r
+ {0.2, 0, 2.7}, {0.2, -0.112, 2.7}, {0.112, -0.2, 2.7}, {0,\r
+ -0.2, 2.7}, {1.3375, 0, 2.53125}, {1.3375, -0.749, 2.53125},\r
+ {0.749, -1.3375, 2.53125}, {0, -1.3375, 2.53125}, {1.4375,\r
+ 0, 2.53125}, {1.4375, -0.805, 2.53125}, {0.805, -1.4375,\r
+ 2.53125}, {0, -1.4375, 2.53125}, {1.5, 0, 2.4}, {1.5, -0.84,\r
+ 2.4}, {0.84, -1.5, 2.4}, {0, -1.5, 2.4}, {1.75, 0, 1.875},\r
+ {1.75, -0.98, 1.875}, {0.98, -1.75, 1.875}, {0, -1.75,\r
+ 1.875}, {2, 0, 1.35}, {2, -1.12, 1.35}, {1.12, -2, 1.35},\r
+ {0, -2, 1.35}, {2, 0, 0.9}, {2, -1.12, 0.9}, {1.12, -2,\r
+ 0.9}, {0, -2, 0.9}, {-2, 0, 0.9}, {2, 0, 0.45}, {2, -1.12,\r
+ 0.45}, {1.12, -2, 0.45}, {0, -2, 0.45}, {1.5, 0, 0.225},\r
+ {1.5, -0.84, 0.225}, {0.84, -1.5, 0.225}, {0, -1.5, 0.225},\r
+ {1.5, 0, 0.15}, {1.5, -0.84, 0.15}, {0.84, -1.5, 0.15}, {0,\r
+ -1.5, 0.15}, {-1.6, 0, 2.025}, {-1.6, -0.3, 2.025}, {-1.5,\r
+ -0.3, 2.25}, {-1.5, 0, 2.25}, {-2.3, 0, 2.025}, {-2.3, -0.3,\r
+ 2.025}, {-2.5, -0.3, 2.25}, {-2.5, 0, 2.25}, {-2.7, 0,\r
+ 2.025}, {-2.7, -0.3, 2.025}, {-3, -0.3, 2.25}, {-3, 0,\r
+ 2.25}, {-2.7, 0, 1.8}, {-2.7, -0.3, 1.8}, {-3, -0.3, 1.8},\r
+ {-3, 0, 1.8}, {-2.7, 0, 1.575}, {-2.7, -0.3, 1.575}, {-3,\r
+ -0.3, 1.35}, {-3, 0, 1.35}, {-2.5, 0, 1.125}, {-2.5, -0.3,\r
+ 1.125}, {-2.65, -0.3, 0.9375}, {-2.65, 0, 0.9375}, {-2,\r
+ -0.3, 0.9}, {-1.9, -0.3, 0.6}, {-1.9, 0, 0.6}, {1.7, 0,\r
+ 1.425}, {1.7, -0.66, 1.425}, {1.7, -0.66, 0.6}, {1.7, 0,\r
+ 0.6}, {2.6, 0, 1.425}, {2.6, -0.66, 1.425}, {3.1, -0.66,\r
+ 0.825}, {3.1, 0, 0.825}, {2.3, 0, 2.1}, {2.3, -0.25, 2.1},\r
+ {2.4, -0.25, 2.025}, {2.4, 0, 2.025}, {2.7, 0, 2.4}, {2.7,\r
+ -0.25, 2.4}, {3.3, -0.25, 2.4}, {3.3, 0, 2.4}, {2.8, 0,\r
+ 2.475}, {2.8, -0.25, 2.475}, {3.525, -0.25, 2.49375},\r
+ {3.525, 0, 2.49375}, {2.9, 0, 2.475}, {2.9, -0.15, 2.475},\r
+ {3.45, -0.15, 2.5125}, {3.45, 0, 2.5125}, {2.8, 0, 2.4},\r
+ {2.8, -0.15, 2.4}, {3.2, -0.15, 2.4}, {3.2, 0, 2.4}, {0, 0,\r
+ 3.15}, {0.8, 0, 3.15}, {0.8, -0.45, 3.15}, {0.45, -0.8,\r
+ 3.15}, {0, -0.8, 3.15}, {0, 0, 2.85}, {1.4, 0, 2.4}, {1.4,\r
+ -0.784, 2.4}, {0.784, -1.4, 2.4}, {0, -1.4, 2.4}, {0.4, 0,\r
+ 2.55}, {0.4, -0.224, 2.55}, {0.224, -0.4, 2.55}, {0, -0.4,\r
+ 2.55}, {1.3, 0, 2.55}, {1.3, -0.728, 2.55}, {0.728, -1.3,\r
+ 2.55}, {0, -1.3, 2.55}, {1.3, 0, 2.4}, {1.3, -0.728, 2.4},\r
+ {0.728, -1.3, 2.4}, {0, -1.3, 2.4}, {0, 0, 0}, {1.425,\r
+ -0.798, 0}, {1.5, 0, 0.075}, {1.425, 0, 0}, {0.798, -1.425,\r
+ 0}, {0, -1.5, 0.075}, {0, -1.425, 0}, {1.5, -0.84, 0.075},\r
+ {0.84, -1.5, 0.075}\r
+};\r
+\r
+static float tex[2][2][2] =\r
+{\r
+ { {0, 0},\r
+ {1, 0}},\r
+ { {0, 1},\r
+ {1, 1}}\r
+};\r
+\r
+/* *INDENT-ON* */\r
+\r
+static void\r
+teapot(GLint grid, GLdouble scale, GLenum type)\r
+{\r
+ float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];\r
+ long i, j, k, l;\r
+\r
+ glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);\r
+ glEnable(GL_AUTO_NORMAL);\r
+ glEnable(GL_NORMALIZE);\r
+ glEnable(GL_MAP2_VERTEX_3);\r
+ glEnable(GL_MAP2_TEXTURE_COORD_2);\r
+ glPushMatrix();\r
+ glRotatef(270.0, 1.0, 0.0, 0.0);\r
+ glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale);\r
+ glTranslatef(0.0, 0.0, -1.5);\r
+ for (i = 0; i < 10; i++) {\r
+ for (j = 0; j < 4; j++) {\r
+ for (k = 0; k < 4; k++) {\r
+ for (l = 0; l < 3; l++) {\r
+ p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];\r
+ q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];\r
+ if (l == 1)\r
+ q[j][k][l] *= -1.0;\r
+ if (i < 6) {\r
+ r[j][k][l] =\r
+ cpdata[patchdata[i][j * 4 + (3 - k)]][l];\r
+ if (l == 0)\r
+ r[j][k][l] *= -1.0;\r
+ s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];\r
+ if (l == 0)\r
+ s[j][k][l] *= -1.0;\r
+ if (l == 1)\r
+ s[j][k][l] *= -1.0;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2,\r
+ &tex[0][0][0]);\r
+ glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,\r
+ &p[0][0][0]);\r
+ glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0);\r
+ glEvalMesh2(type, 0, grid, 0, grid);\r
+ glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,\r
+ &q[0][0][0]);\r
+ glEvalMesh2(type, 0, grid, 0, grid);\r
+ if (i < 6) {\r
+ glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,\r
+ &r[0][0][0]);\r
+ glEvalMesh2(type, 0, grid, 0, grid);\r
+ glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,\r
+ &s[0][0][0]);\r
+ glEvalMesh2(type, 0, grid, 0, grid);\r
+ }\r
+ }\r
+ glPopMatrix();\r
+ glPopAttrib();\r
+}\r
+\r
+/* CENTRY */\r
+void APIENTRY \r
+glutSolidTeapot(GLdouble scale)\r
+{\r
+ teapot(7, scale, GL_FILL);\r
+}\r
+\r
+void APIENTRY \r
+glutWireTeapot(GLdouble scale)\r
+{\r
+ teapot(10, scale, GL_LINE);\r
+}\r
+\r
+/* ENDCENTRY */\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 4.0\r
+ * Copyright (C) 1995-1998 Brian Paul\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Library General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * Library General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Library General Public\r
+ * License along with this library; if not, write to the Free\r
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+\r
+/*\r
+ * DOS/DJGPP glut driver v0.1 for Mesa 4.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+#include "GL/glut.h"\r
+#include "GL/dmesa.h"\r
+#include "internal.h"\r
+\r
+\r
+static DMesaVisual visual = NULL;\r
+static DMesaContext context = NULL;\r
+static DMesaBuffer buffer = NULL;\r
+\r
+\r
+static void clean (void)\r
+{\r
+ __asm__("movw $3, %%ax; int $0x10":::"%eax");\r
+ pc_close_stdout();\r
+ pc_close_stderr();\r
+}\r
+\r
+int APIENTRY glutCreateWindow (const char *title)\r
+{\r
+ if ((visual=DMesaCreateVisual(COLOR_DEPTH,\r
+ g_display_mode & GLUT_DOUBLE,\r
+ g_display_mode & GLUT_DEPTH ?DEPTH_SIZE :0,\r
+ g_display_mode & GLUT_STENCIL?STENCIL_SIZE:0,\r
+ g_display_mode & GLUT_ACCUM ?ACCUM_SIZE :0))==NULL) {\r
+ return GL_FALSE;\r
+ }\r
+\r
+ if ((context=DMesaCreateContext(visual, NULL))==NULL) {\r
+ DMesaDestroyVisual(visual);\r
+ return GL_FALSE;\r
+ }\r
+\r
+ if ((buffer=DMesaCreateBuffer(visual, g_width, g_height, g_xpos, g_ypos))==NULL) {\r
+ DMesaDestroyContext(context);\r
+ DMesaDestroyVisual(visual);\r
+ return GL_FALSE;\r
+ }\r
+\r
+ if (!DMesaMakeCurrent(context, buffer)) {\r
+ DMesaDestroyContext(context);\r
+ DMesaDestroyVisual(visual);\r
+ return GL_FALSE;\r
+ }\r
+\r
+ pc_open_stdout();\r
+ pc_open_stderr();\r
+ pc_atexit(clean);\r
+\r
+ return GL_TRUE;\r
+}\r
+\r
+\r
+int APIENTRY glutCreateSubWindow (int win, int x, int y, int width, int height)\r
+{\r
+ return GL_FALSE;\r
+}\r
+\r
+\r
+void APIENTRY glutDestroyWindow (int win)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutPostRedisplay (void)\r
+{\r
+ g_redisplay = GL_TRUE;\r
+}\r
+\r
+\r
+void APIENTRY glutSwapBuffers (void)\r
+{\r
+ if (g_mouse) pc_scare_mouse();\r
+ DMesaSwapBuffers(buffer);\r
+ if (g_mouse) pc_unscare_mouse();\r
+}\r
+\r
+\r
+int APIENTRY glutGetWindow (void)\r
+{\r
+ return 0;\r
+}\r
+\r
+\r
+void APIENTRY glutSetWindow (int win)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutSetWindowTitle (const char *title)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutSetIconTitle (const char *title)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutPositionWindow (int x, int y)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutReshapeWindow (int width, int height)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutPopWindow (void)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutPushWindow (void)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutIconifyWindow (void)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutShowWindow (void)\r
+{\r
+}\r
+\r
+\r
+void APIENTRY glutHideWindow (void)\r
+{\r
+}\r