--- /dev/null
+/*\r
+ * 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
+\r
+/*\r
+ * DOS/DJGPP device driver v1.3 for Mesa 5.0\r
+ *\r
+ * Copyright (C) 2002 - Borca Daniel\r
+ * Email : dborca@yahoo.com\r
+ * Web : http://www.geocities.com/dborca\r
+ */\r
+\r
+\r
+ .file "blit.S"\r
+\r
+/*\r
+ * extern unsigned int vesa_gran_mask, vesa_gran_shift;\r
+ * extern int vl_video_selector;\r
+\r
+ * extern void *vl_current_draw_buffer;\r
+ * extern int vl_current_stride, vl_current_height;\r
+ * extern int vl_current_offset, vl_current_delta;\r
+ */\r
+\r
+ .text\r
+\r
+/* Desc: VESA bank switching routine (BIOS)\r
+ *\r
+ * In : EBX=0, EDX = bank number\r
+ * Out : -\r
+ *\r
+ * Note: thrashes EAX\r
+ */\r
+ .p2align 5,,31\r
+_vesa_swbankBIOS:\r
+ movw $0x4f05, %ax\r
+ int $0x10\r
+ ret\r
+\r
+ .p2align 2,,3\r
+ .global _vesa_swbank\r
+_vesa_swbank: .long _vesa_swbankBIOS\r
+\r
+/* Desc: void vesa_b_dump_virtual (void);\r
+ *\r
+ * In : -\r
+ * Out : -\r
+ *\r
+ * Note: uses current draw buffer\r
+ */\r
+ .p2align 5,,31\r
+ .global _vesa_b_dump_virtual\r
+_vesa_b_dump_virtual:\r
+ cld\r
+ pushl %es\r
+ pushl %ebx\r
+ pushl %esi\r
+ pushl %edi\r
+ pushl %ebp\r
+ movl _vl_video_selector, %es\r
+ movl _vl_current_draw_buffer, %esi\r
+ movl _vl_current_offset, %edi\r
+ movl _vesa_gran_shift, %ecx\r
+ movl _vesa_gran_mask, %ebp\r
+ movl %edi, %edx\r
+ xorl %ebx, %ebx\r
+ andl %ebp, %edi\r
+ shrl %cl, %edx\r
+ incl %ebp\r
+ call *_vesa_swbank\r
+ movl _vl_current_stride, %ecx\r
+ movl _vl_current_height, %eax\r
+ movl _vl_current_delta, %ebx\r
+ shrl $2, %ecx\r
+ .balign 4\r
+ 0:\r
+ pushl %ecx\r
+ .balign 4\r
+ 1:\r
+ cmpl %ebp, %edi\r
+ jb 2f\r
+ pushl %eax\r
+ pushl %ebx\r
+ incl %edx\r
+ xorl %ebx, %ebx\r
+ call *_vesa_swbank\r
+ popl %ebx\r
+ popl %eax\r
+ subl %ebp, %edi\r
+ .balign 4\r
+ 2:\r
+ movsl\r
+ decl %ecx\r
+ jnz 1b\r
+ popl %ecx\r
+ addl %ebx, %edi\r
+ decl %eax\r
+ jnz 0b\r
+ popl %ebp\r
+ popl %edi\r
+ popl %esi\r
+ popl %ebx\r
+ popl %es\r
+ ret\r
+\r
+/* Desc: void vesa_l_dump_virtual (void);\r
+ *\r
+ * In : -\r
+ * Out : -\r
+ *\r
+ * Note: uses current draw buffer\r
+ */\r
+ .p2align 5,,31\r
+ .global _vesa_l_dump_virtual\r
+_vesa_l_dump_virtual:\r
+ cld\r
+ pushl %es\r
+ pushl %esi\r
+ pushl %edi\r
+ movl _vl_video_selector, %es\r
+ movl _vl_current_draw_buffer, %esi\r
+ movl _vl_current_offset, %edi\r
+ movl _vl_current_stride, %ecx\r
+ movl _vl_current_height, %edx\r
+ movl _vl_current_delta, %eax\r
+ shrl $2, %ecx\r
+ .balign 4\r
+ 0:\r
+ pushl %ecx\r
+ rep; movsl\r
+ popl %ecx\r
+ addl %eax, %edi\r
+ decl %edx\r
+ jnz 0b\r
+ popl %edi\r
+ popl %esi\r
+ popl %es\r
+ ret\r
+\r
+/* Desc: void vesa_l_dump_virtual_mmx (void);\r
+ *\r
+ * In : -\r
+ * Out : -\r
+ *\r
+ * Note: uses current draw buffer\r
+ */\r
+ .p2align 5,,31\r
+ .global _vesa_l_dump_virtual_mmx\r
+_vesa_l_dump_virtual_mmx:\r
+#ifdef USE_MMX_ASM\r
+ pushl %esi\r
+ pushl %edi\r
+ movl _vl_video_selector, %fs\r
+ movl _vl_current_draw_buffer, %esi\r
+ movl _vl_current_offset, %edi\r
+ movl _vl_current_stride, %ecx\r
+ movl _vl_current_height, %edx\r
+ movl _vl_current_delta, %eax\r
+ shrl $3, %ecx\r
+ .balign 4\r
+ 0:\r
+ pushl %ecx\r
+ .balign 4\r
+ 1:\r
+ movq (%esi), %mm0\r
+ addl $8, %esi\r
+ movq %mm0, %fs:(%edi)\r
+ addl $8, %edi\r
+ decl %ecx\r
+ jnz 1b\r
+ popl %ecx\r
+ addl %eax, %edi\r
+ decl %edx\r
+ jnz 0b\r
+ popl %edi\r
+ popl %esi\r
+ emms\r
+#endif\r
+ ret\r
--- /dev/null
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version: 4.1\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
+\r
+/*\r
+ * DOS/DJGPP device driver v1.3 for Mesa 5.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 <stdlib.h>\r
+\r
+#include "vga.h"\r
+\r
+\r
+\r
+static vl_mode modes[4] = {\r
+ {0x13 | 0x4000, 320, 200, 320, 8, -1, 320*200},\r
+ {0xffff, -1, -1, -1, -1, -1, -1}\r
+};\r
+\r
+static word16 vga_ver;\r
+static int linear_selector;\r
+static int oldmode = -1;\r
+\r
+#define vga_color_precision 6\r
+\r
+\r
+\r
+/* Desc: Attempts to detect VGA, check video modes and create selectors.\r
+ *\r
+ * In : -\r
+ * Out : mode array\r
+ *\r
+ * Note: -\r
+ */\r
+static vl_mode *vga_init (void)\r
+{\r
+ int rv = 0;\r
+\r
+ if (vga_ver) {\r
+ return modes;\r
+ }\r
+\r
+ __asm("\n\\r
+ movw $0x1a00, %%ax \n\\r
+ int $0x10 \n\\r
+ cmpb $0x1a, %%al \n\\r
+ jne 0f \n\\r
+ cmpb $0x07, %%bl \n\\r
+ jb 0f \n\\r
+ andl $0xff, %%ebx \n\\r
+ movl %%ebx, %0 \n\\r
+ 0:":"=g"(rv)::"%eax", "%ebx");\r
+ if (rv == 0) {\r
+ return NULL;\r
+ }\r
+\r
+ if (_create_selector(&linear_selector, 0xa0000, 0x10000)) {\r
+ return NULL;\r
+ }\r
+\r
+ modes[0].sel = linear_selector;\r
+\r
+ vga_ver = rv;\r
+ return modes;\r
+}\r
+\r
+\r
+\r
+/* Desc: Frees all resources allocated by VGA init code.\r
+ *\r
+ * In : -\r
+ * Out : -\r
+ *\r
+ * Note: -\r
+ */\r
+static void vga_finit (void)\r
+{\r
+ if (vga_ver) {\r
+ _remove_selector(&linear_selector);\r
+ }\r
+}\r
+\r
+\r
+\r
+/* Desc: Attempts to enter specified video mode.\r
+ *\r
+ * In : ptr to mode structure, refresh rate\r
+ * Out : 0 if success\r
+ *\r
+ * Note: -\r
+ */\r
+static int vga_entermode (vl_mode *p, int refresh)\r
+{\r
+ if (!(p->mode & 0x4000)) {\r
+ return -1;\r
+ }\r
+ VGA.blit = vl_can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual;\r
+\r
+ if (oldmode == -1) {\r
+ __asm("\n\\r
+ movb $0x0f, %%ah \n\\r
+ int $0x10 \n\\r
+ andl $0xff, %%eax \n\\r
+ movl %%eax, %0 \n\\r
+ ":"=g"(oldmode)::"%eax", "%ebx");\r
+ }\r
+\r
+ __asm("int $0x10"::"a"(p->mode&0xff));\r
+\r
+ return 0;\r
+}\r
+\r
+\r
+\r
+/* Desc: Restores to the mode prior to first call to vga_entermode.\r
+ *\r
+ * In : -\r
+ * Out : -\r
+ *\r
+ * Note: -\r
+ */\r
+static void vga_restore (void)\r
+{\r
+ if (oldmode != -1) {\r
+ __asm("int $0x10"::"a"(oldmode));\r
+ }\r
+}\r
+\r
+\r
+\r
+/* Desc: set one palette entry\r
+ *\r
+ * In : color index, R, G, B\r
+ * Out : -\r
+ *\r
+ * Note: uses normalized values\r
+ */\r
+static void vga_setCI_f (int index, float red, float green, float blue)\r
+{\r
+ float max = (1 << vga_color_precision) - 1;\r
+\r
+ int _red = red * max;\r
+ int _green = green * max;\r
+ int _blue = blue * max;\r
+\r
+ __asm("\n\\r
+ movw $0x1010, %%ax \n\\r
+ movb %1, %%dh \n\\r
+ movb %2, %%ch \n\\r
+ int $0x10 \n\\r
+ "::"b"(index), "m"(_red), "m"(_green), "c"(_blue):"%eax", "%edx");\r
+}\r
+\r
+\r
+\r
+/* Desc: set one palette entry\r
+ *\r
+ * In : color index, R, G, B\r
+ * Out : -\r
+ *\r
+ * Note: uses integer values\r
+ */\r
+static void vga_setCI_i (int index, int red, int green, int blue)\r
+{\r
+ __asm("\n\\r
+ movw $0x1010, %%ax \n\\r
+ movb %1, %%dh \n\\r
+ movb %2, %%ch \n\\r
+ int $0x10 \n\\r
+"::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx");\r
+}\r
+\r
+\r
+\r
+/* Desc: retrieve CI precision\r
+ *\r
+ * In : -\r
+ * Out : precision in bits\r
+ *\r
+ * Note: -\r
+ */\r
+static int vga_getCIprec (void)\r
+{\r
+ return vga_color_precision;\r
+}\r
+\r
+\r
+\r
+/*\r
+ * the driver\r
+ */\r
+vl_driver VGA = {\r
+ vga_init,\r
+ vga_entermode,\r
+ NULL,\r
+ vga_setCI_f,\r
+ vga_setCI_i,\r
+ vga_getCIprec,\r
+ vga_restore,\r
+ vga_finit\r
+};\r
--- /dev/null
+/*\r
+ * 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
+\r
+/*\r
+ * DOS/DJGPP device driver v1.3 for Mesa 5.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 VGA_H_included\r
+#define VGA_H_included\r
+\r
+#include "../internal.h"\r
+#include "../vesa/vesa.h"\r
+\r
+extern vl_driver VGA;\r
+\r
+#endif\r