+++ /dev/null
-/* $Id: dosmesa.c,v 1.4 2001/03/03 20:33:29 brianp Exp $ */\r
-\r
-/*\r
- * Mesa 3-D graphics library\r
- * Version: 2.3\r
- * Copyright (C) 1995-1997 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
-/*\r
- * $Log: dosmesa.c,v $
- * Revision 1.4 2001/03/03 20:33:29 brianp
- * lots of gl_*() to _mesa_*() namespace clean-up
- *
- * Revision 1.3 2000/11/22 08:55:52 joukj
- *
- *
- * Modified Files:
- * Mesa/src/Allegro/amesa.c Mesa/src/DOS/dosmesa.c
- * Mesa/src/FX/fxdd.c Mesa/src/FX/fxdrv.h
- * Mesa/src/FX/fxfastpath.c
- * Mesa/src/GGI/include/ggi/mesa/ggimesa.h
- * Mesa/src/OSmesa/osmesa.c Mesa/src/SVGA/svgamesa.c
- * Mesa/src/Trace/tr_control.c Mesa/src/Windows/wgl.c
- * Mesa/src/X/xmesaP.h Mesa/src/X86/3dnow.c Mesa/src/X86/katmai.c
- * Mesa/src/X86/x86.c
- * Removed Files:
- * Mesa/src/mms_depend
- *
- * Oops,... all files containing Caps in directory name or file name were
- * missing in my types->mtypes commit.
- *
- * ----------------------------------------------------------------------
- *
- * Revision 1.2 2000/09/26 20:54:10 brianp
- * First batch of OpenGL SI related changes:
- * Renamed struct gl_context to struct __GLcontextRec.
- * Include glcore.h, setup GL imports/exports.
- * Replaced gl_ prefix with _mesa_ prefix in context.[ch] functions.
- * GLcontext's Visual field is no longer a pointer.
- *
- * Revision 1.1.1.1 1999/08/19 00:55:41 jtg
- * Imported sources
- *
- * Revision 1.2 1999/03/28 21:11:57 brianp
- * updated SetBuffer driver function
- *
- * Revision 1.1 1999/02/24 03:56:31 brianp
- * initial check-in
- *\r
- *
- * Revision 1.5 1997/06/19 22:00:00 Brian Paul\r
- * Removed all ColorShift stuff
- *\r
- * Revision 1.4 1997/06/03 19:00:00 Brian Paul\r
- * Replaced VB->Unclipped[] with VB->ClipMask[]\r
- *\r
- * Revision 1.3 1997/05/28 07:00:00 Phil Frisbie, Jr.\r
- * Now pass red/green/blue/alpha bits to gl_create_visual()\r
- * Fixed DJGPP mode 13 support.\r
- *\r
- * Revision 1.2 1996/12/08 16:13:45 Charlie\r
- * Added VESA support via Scitechs SVGA kit.\r
- *\r
- * Revision 1.1 1996/12/08 16:09:52 Charlie\r
- * Initial revision\r
- *\r
- */\r
-\r
-\r
-/*\r
- * DOS VGA/VESA/MGL/Mesa interface.\r
- *\r
- */\r
-\r
-/*\r
- *\r
- * TODO: (cw)\r
- * Improve the colour matcher for rgb non vesa modes, its pretty bad and incorrect\r
- * Keyboard interrupt.\r
- * Comments and tidy up.\r
- * Add support for VESA without SVGAKIT.\r
- * DirectX Support.\r
- * Better GLIDE Support.\r
- * Clear up the #ifdef madness.\r
- */\r
-\r
-#ifdef DOSVGA\r
-\r
-#if defined(DOSVGA) && !defined(GLIDE) && defined(DJGPP) && !defined(UNIVBE) && !defined(MGL)\r
-\r
-/* Should help cut down on the crazy #if`s */\r
-#define MODE13 1\r
-\r
-#else\r
-#undef MODE13\r
-#endif\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <string.h>\r
-#include <dos.h>\r
-\r
-#ifdef DJGPP\r
-#include <go32.h>\r
-#endif\r
-\r
-#ifdef MGL\r
-#include <mgraph.h>\r
-#endif\r
-\r
-#include "GL/DOSmesa.h"\r
-#include "context.h"\r
-#include "matrix.h"\r
-#include "mtypes.h"
-\r
-#ifdef GLIDE\r
-\r
-static void glideshutdown( void );\r
-#include "vb.h"\r
-#include "glide.h"\r
-\r
-/* the glide modes available, set one */\r
-\r
-//#define GLIDE_MODE GR_RESOLUTION_\r
-#define GLIDE_MODE GR_RESOLUTION_800x600\r
-//#define GLIDE_MODE GR_RESOLUTION_640x480\r
-\r
-static GrVertex gr_vtx,gr_vtx1,gr_vtx2;\r
-\r
-#endif\r
-\r
-#ifdef UNIVBE\r
-/* You get this file from Scitechs VESA development kit */\r
-#include "svga.h"\r
-\r
-/*\r
- Set these to the VESA mode you require, the first is for 256 colour modes,\r
- the other is High colour modes, they must both be the same XRes and YRes.\r
- */\r
-\r
-#define VESA_256COLOUR_MODE 0x11c\r
-#define VESA_HICOLOUR_MODE 0x11f\r
-\r
-#endif\r
-\r
-struct DOSmesa_context {\r
- GLcontext *gl_ctx; /* the core Mesa context */\r
- GLvisual *gl_vis; /* describes the color buffer */\r
- GLframebuffer *gl_buffer; /* the ancillary buffers */\r
- GLuint index; /* current color index */\r
- GLint red, green, blue; /* current rgb color */\r
- GLint width, height; /* size of color buffer */\r
- GLint depth; /* bits per pixel (8,16,24 or 32) */\r
-};\r
-\r
-static DOSMesaContext DOSMesa = NULL; /* the current context */\r
-\r
-#ifdef UNIVBE\r
-SV_devCtx *DC=NULL;\r
-int useLinear = TRUE;\r
-SV_modeInfo *mi=NULL;\r
-unsigned long modeNumber = 0;\r
-\r
-int activePage = 0;\r
-int visualPage = 1;\r
-\r
-#endif\r
-\r
-#if defined(MODE13)\r
-\r
-/* DOSVGA With no UniVBE support */\r
-\r
-unsigned char *video_buffer;\r
-\r
-#define VID_BUF(x,y) *(video_buffer+x+(y*320))\r
-\r
-#if defined(__WATCOMC__) && defined(__386__) && defined(__DOS__)\r
-\r
-void setupcopy(void);\r
-void copyscr(void);\r
-\r
-/* Watcom C specfic, screen copy and clear */\r
-\r
-#pragma aux setupcopy = \\r
- ".386P"\\r
- "push ebp" \\r
- "mov esi,video_buffer" \\r
- "mov edi,0xa0000" \\r
- "mov ecx,2000" \\r
- "xor ebp,ebp";\r
-\r
-#pragma aux copyscr = \\r
- ".386P" \\r
- "lop1: mov eax,[esi]"\\r
- "mov ebx,[esi+4]"\\r
- "mov edx,[esi+8]"\\r
- "mov [edi],eax"\\r
- "mov eax,[esi+12]"\\r
- "mov dword ptr [esi],ebp"\\r
- "mov dword ptr [esi+4],ebp"\\r
- "mov dword ptr [esi+8],ebp"\\r
- "mov dword ptr [esi+12],ebp"\\r
- "mov [edi+4],ebx"\\r
- "mov [edi+8],edx"\\r
- "mov [edi+12],eax"\\r
- "mov eax,[esi+16]"\\r
- "mov ebx,[esi+4+16]"\\r
- "mov edx,[esi+8+16]"\\r
- "mov [edi+16],eax"\\r
- "mov eax,[esi+12+16]"\\r
- "mov dword ptr [esi+16],ebp"\\r
- "mov dword ptr [esi+4+16],ebp"\\r
- "mov dword ptr [esi+8+16],ebp"\\r
- "mov dword ptr [esi+12+16],ebp"\\r
- "mov [edi+4+16],ebx"\\r
- "mov [edi+8+16],edx"\\r
- "mov [edi+12+16],eax"\\r
- "add esi,32"\\r
- "add edi,32"\\r
- "dec ecx"\\r
- "jnz lop1"\\r
- "pop ebp"\\r
- modify exact [edi esi eax ebx ecx] ;\r
-\r
-#endif // WATCOM\r
-\r
-#endif // MODE13\r
-\r
-/*\r
- * Convert Mesa window Y coordinate to VGA screen Y coordinate:\r
- */\r
-#define FLIP(Y) (DOSMesa->height-(Y)-1)\r
-\r
-unsigned short vga_cindex = 32768 ;\r
-\r
-static points_func choose_points_function( void );\r
-static line_func choose_line_function( void );\r
-static triangle_func choose_polygon_function( void );\r
-static void fast_tri(GLcontext *ctx,GLuint v0, GLuint v1, GLuint v2, GLuint pv );\r
-\r
-static points_func choose_points_function( void )\r
-{\r
- return NULL;\r
-}\r
-\r
-static line_func choose_line_function( void )\r
-{\r
- return NULL;\r
-}\r
-\r
-static triangle_func choose_triangle_function( void )\r
-{\r
- #if defined(MODE13)\r
- return NULL;\r
- #endif\r
-\r
- #if defined(GLIDE)\r
- return fast_tri;\r
- #endif\r
-\r
- return NULL;\r
-}\r
-\r
-\r
-#if defined(MODE13)\r
-\r
-void setgfxmode(void);\r
-void settextmode(void);\r
-\r
-#ifndef DJGPP\r
-#pragma aux setgfxmode = \\r
- "mov ax,13h" \\r
- "int 10h" \\r
- modify [eax];\r
-\r
-#pragma aux settextmode = \\r
- "mov ax,3h" \\r
- "int 10h" \\r
- modify [eax];\r
-#else\r
-void setgfxmode(void)\r
-{\r
- union REGS in_regs,out_regs;\r
-\r
- in_regs.x.ax = 0x13;\r
- int386(0x10,&in_regs,&out_regs);\r
-}\r
-\r
-void settextmode(void)\r
-{\r
- union REGS in_regs,out_regs;\r
-\r
- in_regs.x.ax = 0x3;\r
- int386(0x10,&in_regs,&out_regs);\r
-}\r
-\r
-#endif\r
-\r
-int set_video_mode(unsigned short x,unsigned short y,char mode)\r
-{\r
- setgfxmode();\r
- return 1; /* likelyhood of this failing is very small */\r
-}\r
-\r
-void restore_video_mode(void)\r
-{\r
- settextmode();\r
-}\r
-\r
-int vga_getcolors(void)\r
-{\r
- return vga_cindex;\r
-}\r
-\r
-int vga_getxdim(void)\r
-{\r
- return 320;\r
-}\r
-\r
-int vga_getydim(void)\r
-{\r
- return 200;\r
-}\r
-\r
-static unsigned short num_rgb_alloc = 1; /* start from 1, zero is black */\r
-\r
-/* an unlikely colour */\r
-static unsigned char last_r=1,last_g=255,last_b=99;\r
-\r
-extern void set_onecolor(int index,int R,int G,int B);\r
-\r
-static unsigned char rgbtable[64][64][64];\r
-\r
-void vga_setrgbcolor(int r,int g,int b)\r
-{\r
-\r
-/*\r
- * make this into a translation table\r
- */\r
-\r
- DOSMesa->red = r;\r
- DOSMesa->green = g ;\r
- DOSMesa->blue = b ;\r
-\r
- r/=4; g/=4; b/=4;\r
-\r
- if( (r == last_r) && (g == last_g) && (b == last_b) ) return;\r
-\r
- last_r = r ;\r
- last_g = g ;\r
- last_b = b ;\r
-\r
- if(r+g+b == 0 ) {\r
- DOSMesa->index = 0 ;\r
- return ;\r
- }\r
-\r
- if( rgbtable[r][g][b] == 0 ) {\r
- /* not allocated yet */\r
- if(num_rgb_alloc<256) {\r
- DOSMesa->index = num_rgb_alloc;\r
- set_onecolor(num_rgb_alloc,r,g,b);\r
- rgbtable[r][g][b] = num_rgb_alloc;\r
- num_rgb_alloc++;\r
- return;\r
-\r
- } else {\r
- /* need to search for a close colour */\r
- {\r
- unsigned short pass ;\r
-\r
- for(pass=0;pass<64;pass++) {\r
- if(r-pass>0) {\r
- if( rgbtable[r-pass][g][b] !=0 ) {\r
- rgbtable[r][g][b] = rgbtable[r-pass][g][b];\r
- DOSMesa->index = rgbtable[r-pass][g][b];\r
- return;\r
- }\r
- }\r
- if(r+pass<64) {\r
- if( rgbtable[r+pass][g][b] !=0 ) {\r
- rgbtable[r][g][b] = rgbtable[r+pass][g][b];\r
- DOSMesa->index = rgbtable[r+pass][g][b];\r
- return;\r
- }\r
- }\r
- }\r
- }\r
- rgbtable[r][g][b] = rand()%255;\r
- }\r
- }\r
- DOSMesa->index = rgbtable[r][g][b];\r
-}\r
-\r
-#if defined(DJGPP)\r
-static int dos_seg;\r
-#endif\r
-\r
-void vga_clear(void)\r
-{\r
-\r
-/* Check if we`re using watcom and DOS */\r
-#if defined(__WATCOMC__) && defined(__386__) && defined(__DOS__)\r
- setupcopy();\r
- copyscr();\r
-#else\r
-\r
-#if defined (DJGPP)\r
-\r
-\r
- asm ("\r
- pusha\r
- pushw %es\r
-\r
- movw _dos_seg, %es\r
-\r
- movl _video_buffer, %esi\r
- movl $0xa0000, %edi\r
-\r
- movl $64000, %ecx\r
-\r
- rep ; movsb\r
-\r
- popw %es\r
- popa\r
- ");\r
-\r
-#else\r
-\r
- /* copy the RAM buffer to the Video memory */\r
- memcpy((unsigned char *)0xa0000,video_buffer, vga_getxdim()*vga_getydim() );\r
-\r
-#endif //DJGPP\r
-\r
- /* clear the RAM buffer */\r
- memset(video_buffer,0, vga_getxdim()*vga_getydim() );\r
-\r
-#endif //WATCOMC\r
-\r
-}\r
-\r
-#ifndef DEBUG\r
-#define vga_drawpixel(x,y) { VID_BUF(x,y) = DOSMesa->index; }\r
-#else\r
-void vga_drawpixel(x,y)\r
-{\r
- VID_BUF(x,y) = DOSMesa->index;\r
-}\r
-#endif\r
-\r
-int vga_getpixel(int x,int y)\r
-{\r
- return 1;\r
-}\r
-\r
-void vga_flip(void)\r
-{\r
-\r
-}\r
-\r
-void vga_setcolor(int index)\r
-{\r
- /* does something, what i`ve no idea */\r
- DOSMesa->index = index;\r
-\r
-}\r
-\r
-#endif\r
-\r
-#if defined(UNIVBE)\r
-\r
-/* UniVBE VESA support */\r
-\r
-void set_video_mode(unsigned short x,unsigned short y,char mode)\r
-{\r
- if( setup_vesa_mode(x,y,mode) == FALSE ) {\r
- fprintf(stderr,"VESA: Set mode failed\n");\r
- exit(1);\r
- }\r
-}\r
-\r
-/*\r
- This is problematic as we don`t know what resolution the user program\r
- wants when we reach here. This is why the 256 colour and HiColour modes\r
- should be the same resolution, perhaps i`ll make this an environment\r
- variable\r
- */\r
-\r
-\r
-void check_mi(void)\r
-{\r
- if(mi!=0) return;\r
-\r
- if(DC==NULL) {\r
- DC = SV_init( TRUE );\r
- }\r
-\r
- if(modeNumber == 0 ) {\r
- modeNumber = VESA_HICOLOUR_MODE;\r
- }\r
-\r
- SV_getModeInfo(modeNumber,mi);\r
-\r
- return;\r
-}\r
-\r
-int setup_vesa_mode(short height,short width,short depth)\r
-{\r
- if(DC==NULL) {\r
- DC = SV_init( TRUE );\r
- /* how many bits per pixel */\r
- if( depth == 0)\r
- modeNumber = VESA_256COLOUR_MODE;\r
- else\r
- modeNumber = VESA_HICOLOUR_MODE;\r
- }\r
-\r
- /* Check if correct VESA Version is available */\r
- if( !DC || DC->VBEVersion < 0x0102) {\r
- fprintf(stderr,"Require a VESA VBE version 1.2 or higher\n");\r
- return FALSE;\r
- }\r
-\r
- /* Check for LFB Supprt */\r
- if(DC->VBEVersion < 0x0200 ) {\r
- useLinear = FALSE;\r
- } else {\r
- useLinear = TRUE ;\r
- }\r
-\r
- /* Get desired mode info */\r
- if(!SV_getModeInfo( modeNumber, mi))\r
- return FALSE;\r
-\r
- /* Set VESA mode */\r
- if(!SV_setMode(modeNumber | svMultiBuffer, FALSE, TRUE, mi->NumberOfPages) )\r
- return FALSE;\r
-\r
- return TRUE;\r
-}\r
-\r
-void restore_video_mode(void)\r
-{\r
- SV_restoreMode();\r
-}\r
-\r
-void vga_clear(void)\r
-{\r
- SV_clear(0);\r
-}\r
-\r
-void vga_flip(void)\r
-{\r
- activePage = 1-activePage;\r
- visualPage = 1-activePage;\r
-\r
- SV_setActivePage(activePage);\r
-\r
- /*\r
- Change false to true if you`re getting flickering\r
- even in double buffer mode, ( sets wait for Vertical retrace )\r
- */\r
- SV_setVisualPage(visualPage,false);\r
-}\r
-\r
-int vga_getcolors(void)\r
-{\r
- check_mi();\r
- switch ( mi->BitsPerPixel ) {\r
- case 8:\r
- return 256;\r
- case 15:\r
- case 16:\r
- return 32768;\r
- default:\r
- return 64000;\r
- }\r
-}\r
-\r
-int vga_getxdim(void)\r
-{\r
- check_mi();\r
- return mi->XResolution;\r
-}\r
-\r
-int vga_getydim(void)\r
-{\r
- check_mi();\r
- return mi->YResolution;\r
-}\r
-\r
-unsigned long current_color = 255;\r
-\r
-void vga_setrgbcolor(int r,int g,int b)\r
-{\r
- DOSMesa->red = r;\r
- DOSMesa->green = g ;\r
- DOSMesa->blue = b ;\r
- current_color = SV_rgbColor(r,g,b);\r
-}\r
-\r
-void vga_setcolor(int index)\r
-{\r
- DOSMesa->index = index;\r
- current_color = index;\r
-}\r
-\r
-void vga_drawpixel(x,y)\r
-{\r
- SV_putPixel(x,y,current_color);\r
-}\r
-\r
-/* TODO: */\r
-int vga_getpixel(x,y)\r
-{\r
-/* return (int)SV_getPixel(x,y); */\r
- fprintf(stderr,"vga_getpixel: Not implemented yet\n");\r
- return 1;\r
-}\r
-\r
-/* End of UNIVBE section */\r
-#endif\r
-\r
-/* Scitechs MegaGraphicsLibrary http://www.scitechsoft.com/ */\r
-\r
-#if defined(MGL)\r
-\r
-/* MGL support */\r
-struct MI {\r
- unsigned short BitsPerPixel;\r
- unsigned long XResolution;\r
- unsigned long YResolution;\r
-};\r
-\r
-struct MI*mi;\r
-\r
-static MGLDC*DC;\r
-static int activePage = 0;\r
-static int visualPage = 1;\r
-static int modeNumber = 0;\r
-\r
-void set_video_mode(unsigned short xres,unsigned short yres,char mode)\r
-{\r
- int i,driver = grDETECT,dmode = grDETECT;\r
- event_t evt;\r
-\r
- /* Start the MGL with only the SVGA 16m driver active */\r
- MGL_registerDriver(MGL_SVGA16NAME,SVGA16_driver);\r
- if (!MGL_init(&driver,&dmode,"..\\..\\"))\r
- MGL_fatalError(MGL_errorMsg(MGL_result()));\r
- if ((DC = MGL_createDisplayDC(false)) == NULL)\r
- MGL_fatalError(MGL_errorMsg(MGL_result()));\r
- MGL_makeCurrentDC(DC);\r
-}\r
-\r
-/*\r
- This is problematic as we don`t know what resolution the user program\r
- wants when we reach here. This is why the 256 colour and HiColour modes\r
- should be the same resolution, perhaps i`ll make this an environment\r
- variable\r
- */\r
-\r
-#define MGL_HICOLOUR_MODE 0\r
-\r
-\r
-void check_mi(void)\r
-{\r
- if(mi!=0) return;\r
-\r
- if(DC==NULL) {\r
-// DC = SV_init( TRUE );\r
- }\r
-\r
- if(modeNumber == 0 ) {\r
- modeNumber = MGL_HICOLOUR_MODE;\r
- }\r
-\r
-// SV_getModeInfo(modeNumber,mi);\r
-\r
- return;\r
-}\r
-\r
-void restore_video_mode(void)\r
-{\r
- MGL_exit();\r
-}\r
-\r
-void vga_clear(void)\r
-{\r
- MGL_clearDevice();\r
-}\r
-\r
-void vga_flip(void)\r
-{\r
- activePage = 1-activePage;\r
- visualPage = 1-activePage;\r
-\r
-// SV_setActivePage(activePage);\r
-\r
- /*\r
- Change false to true if you`re getting flickering\r
- even in double buffer mode, ( sets wait for Vertical retrace )\r
- */\r
-// SV_setVisualPage(visualPage,false);\r
-}\r
-\r
-int vga_getcolors(void)\r
-{\r
- check_mi();\r
- switch ( mi->BitsPerPixel ) {\r
- case 8:\r
- return 256;\r
- case 15:\r
- case 16:\r
- return 32768;\r
- default:\r
- return 64000;\r
- }\r
-}\r
-\r
-int vga_getxdim(void)\r
-{\r
- check_mi();\r
- return mi->XResolution;\r
-}\r
-\r
-int vga_getydim(void)\r
-{\r
- check_mi();\r
- return mi->YResolution;\r
-}\r
-\r
-unsigned long current_color = 255;\r
-\r
-void vga_setrgbcolor(int r,int g,int b)\r
-{\r
- DOSMesa->red = r;\r
- DOSMesa->green = g ;\r
- DOSMesa->blue = b ;\r
- current_color = MGL_rgbColor(DC,r,g,b);\r
-}\r
-\r
-void vga_setcolor(int index)\r
-{\r
- DOSMesa->index = index;\r
- current_color = index;\r
-}\r
-\r
-void vga_drawpixel(x,y)\r
-{\r
- MGL_pixelCoord(x,y);\r
-}\r
-\r
-/* TODO: */\r
-int vga_getpixel(x,y)\r
-{\r
-/* return (int)SV_getPixel(x,y); */\r
- fprintf(stderr,"vga_getpixel: Not implemented yet\n");\r
- return 1;\r
-}\r
-\r
-/* End of UNIVBE section */\r
-#endif\r
-\r
-#ifdef GLIDE\r
-\r
-/* GLIDE support */\r
-\r
-static GrHwConfiguration hwconfig;\r
-\r
-void set_video_mode(unsigned short x,unsigned short y,char mode)\r
-{\r
- grGlideInit();\r
- if( grSstQueryHardware( &hwconfig ) ) {\r
- grSstSelect( 0 ) ;\r
- if( !grSstOpen( GLIDE_MODE,\r
- GR_REFRESH_60Hz,\r
- GR_COLORFORMAT_ABGR,\r
- GR_ORIGIN_UPPER_LEFT,\r
- GR_SMOOTHING_ENABLE,\r
- 2 ) ) {\r
- fprintf(stderr,"Detected 3DFX board, but couldn`t initialize!");\r
- exit(1);\r
- }\r
-\r
- grBufferClear( 0, 0, GR_WDEPTHVALUE_FARTHEST);\r
-\r
- grDisableAllEffects();\r
- atexit( glideshutdown );\r
-\r
-// guColorCombineFunction( GR_COLORCOMBINE_ITRGB );\r
-// grTexCombineFunction( GR_TMU0, GR_TEXTURECOMBINE_ZERO);\r
- }\r
-}\r
-\r
-void restore_video_mode(void)\r
-{\r
-}\r
-\r
-static void glideshutdown( void )\r
-{\r
- grGlideShutdown() ;\r
-}\r
-\r
-void vga_clear(void)\r
-{\r
- grBufferSwap(0);\r
- grBufferClear( 0, 0, GR_WDEPTHVALUE_FARTHEST);\r
-}\r
-\r
-void vga_flip(void)\r
-{\r
-}\r
-\r
-int vga_getcolors(void)\r
-{\r
- return 32768;\r
-}\r
-\r
-int vga_getxdim(void)\r
-{\r
-#if GLIDE_MODE == GR_RESOLUTION_800x600\r
- return 800;\r
-#else\r
- return 640;\r
-#endif\r
-}\r
-\r
-int vga_getydim(void)\r
-{\r
-#if GLIDE_MODE == GR_RESOLUTION_800x600\r
- return 600;\r
-#else\r
- return 480;\r
-#endif\r
-}\r
-\r
-unsigned long current_color = 255;\r
-\r
-void vga_setrgbcolor(int r,int g,int b)\r
-{\r
- DOSMesa->red = r;\r
- DOSMesa->green = g ;\r
- DOSMesa->blue = b ;\r
-}\r
-\r
-void vga_setcolor(int index)\r
-{\r
- DOSMesa->index = index;\r
-}\r
-\r
-void vga_drawpixel(x,y)\r
-{\r
-\r
- gr_vtx.x = x;\r
- gr_vtx.y = y;\r
- gr_vtx.z = 0;\r
- gr_vtx.r = DOSMesa->red;\r
- gr_vtx.g = DOSMesa->green;\r
- gr_vtx.b = DOSMesa->blue;\r
-\r
- grDrawPoint( &gr_vtx );\r
-}\r
-\r
-static void fast_tri(GLcontext *ctx,GLuint v0, GLuint v1, GLuint v2, GLuint pv )\r
-{\r
- struct vertex_buffer *VB = ctx->VB;\r
-\r
- gr_vtx.z = 0;\r
- gr_vtx1.z = 0;\r
- gr_vtx2.z = 0;\r
-\r
- if (VB->MonoColor) {\r
- gr_vtx.r = DOSMesa->red;\r
- gr_vtx.g = DOSMesa->green;\r
- gr_vtx.b = DOSMesa->blue;\r
- gr_vtx1.r = DOSMesa->red;\r
- gr_vtx1.g = DOSMesa->green;\r
- gr_vtx1.b = DOSMesa->blue;\r
- gr_vtx2.r = DOSMesa->red;\r
- gr_vtx2.g = DOSMesa->green;\r
- gr_vtx2.b = DOSMesa->blue;\r
- } else {\r
- if(ctx->Light.ShadeModel == GL_SMOOTH ) {\r
- gr_vtx.r = FixedToInt( VB->Color[v0][0] );\r
- gr_vtx.g = FixedToInt( VB->Color[v0][1] );\r
- gr_vtx.b = FixedToInt( VB->Color[v0][2] );\r
-\r
- gr_vtx1.r = FixedToInt( VB->Color[v1][0] );\r
- gr_vtx1.g = FixedToInt( VB->Color[v1][1] );\r
- gr_vtx1.b = FixedToInt( VB->Color[v1][2] );\r
-\r
- gr_vtx2.r = FixedToInt( VB->Color[v2][0] );\r
- gr_vtx2.g = FixedToInt( VB->Color[v2][1] );\r
- gr_vtx2.b = FixedToInt( VB->Color[v2][2] );\r
- } else {\r
- gr_vtx.r = VB->Color[pv][0];\r
- gr_vtx.g = VB->Color[pv][1];\r
- gr_vtx.b = VB->Color[pv][2];\r
-\r
- gr_vtx1.r = VB->Color[pv][0];\r
- gr_vtx1.g = VB->Color[pv][1];\r
- gr_vtx1.b = VB->Color[pv][2];\r
-\r
- gr_vtx2.r = VB->Color[pv][0];\r
- gr_vtx2.g = VB->Color[pv][1];\r
- gr_vtx2.b = VB->Color[pv][2];\r
- }\r
- }\r
-\r
- gr_vtx.x = (VB->Win[v0][0] );\r
- gr_vtx.y = FLIP( (VB->Win[v0][1] ) );\r
- gr_vtx1.x = (VB->Win[v1][0] );\r
- gr_vtx1.y = FLIP( (VB->Win[v1][1] ) );\r
- gr_vtx2.x = (VB->Win[v2][0] );\r
- gr_vtx2.y = FLIP( (VB->Win[v2][1] ) );\r
-\r
- if(gr_vtx.x <0 || gr_vtx.x > 639 )\r
- return;\r
- if(gr_vtx1.x <0 || gr_vtx1.x > 639 )\r
- return;\r
- if(gr_vtx2.x <0 || gr_vtx2.x > 639 )\r
- return;\r
-\r
- if(gr_vtx.y <0 || gr_vtx.y > 479 )\r
- return;\r
- if(gr_vtx1.y <0 || gr_vtx1.y > 479 )\r
- return;\r
- if(gr_vtx2.y <0 || gr_vtx2.y > 479 )\r
- return;\r
-\r
- grDrawTriangle( &gr_vtx,&gr_vtx1,&gr_vtx2);\r
-}\r
-\r
-void fast_plot(GLcontext *ctx,GLuint first,GLuint last )\r
-{\r
- struct vertex_buffer *VB = ctx->VB;\r
- register GLuint i;\r
-\r
- if(VB->MonoColor) {\r
- /* all same color */\r
-\r
- gr_vtx.r = DOSMesa->red;\r
- gr_vtx.g = DOSMesa->green;\r
- gr_vtx.b = DOSMesa->blue;\r
-\r
- for(i=first;i<last;i++) {\r
- if(VB->ClipMask[i]==0) {\r
- gr_vtx.x = VB->Win[i][0];\r
- gr_vtx.y = FLIP(VB->Win[i][1]);\r
- }\r
- }\r
- }\r
-}\r
-\r
-/* TODO: */\r
-int vga_getpixel(x,y)\r
-{\r
-/* return (int)SV_getPixel(x,y); */\r
- fprintf(stderr,"vga_getpixel: Not implemented yet\n");\r
- return 1;\r
-}\r
-\r
-/* End of GLIDE section */\r
-\r
-#endif // GLIDE\r
-/**********************************************************************/\r
-/***** Miscellaneous functions *****/\r
-/**********************************************************************/\r
-\r
-\r
-static void get_buffer_size( GLcontext *ctx, GLuint *width, GLuint *height )\r
-{\r
- *width = DOSMesa->width = vga_getxdim();\r
- *height = DOSMesa->height = vga_getydim();\r
-}\r
-\r
-\r
-/* Set current color index */\r
-static void set_index( GLcontext *ctx, GLuint index )\r
-{\r
- DOSMesa->index = index;\r
- /*vga_setcolor( index );*/\r
-}\r
-\r
-\r
-/* Set current drawing color */\r
-static void set_color( GLcontext *ctx,\r
- GLubyte red, GLubyte green,\r
- GLubyte blue, GLubyte alpha )\r
-{\r
- DOSMesa->red = red;\r
- DOSMesa->green = green;\r
- DOSMesa->blue = blue;\r
- vga_setrgbcolor( red, green, blue );\r
-}\r
-\r
-\r
-static void clear_index( GLcontext *ctx, GLuint index )\r
-{\r
- /* TODO: Implements glClearIndex() */\r
-}\r
-\r
-\r
-static void clear_color( GLcontext *ctx,\r
- GLubyte red, GLubyte green,\r
- GLubyte blue, GLubyte alpha )\r
-{\r
- /* TODO: Implements glClearColor() */\r
-}\r
-\r
-\r
-static void clear( GLcontext *ctx,\r
- GLboolean all,\r
- GLint x, GLint y, GLint width, GLint height )\r
-{\r
- vga_clear();\r
-}\r
-\r
-\r
-static GLboolean set_buffer( GLcontext *ctx,\r
- GLenum mode )\r
-{\r
- /* TODO: implement double buffering and use this function to select */\r
- /* between front and back buffers. */\r
- if (buffer == GL_FRONT_LEFT)\r
- return GL_TRUE;\r
- else if (buffer == GL_BACK_LEFT)\r
- return GL_TRUE;\r
- else\r
- return GL_FALSE;\r
-}\r
-\r
-\r
-\r
-\r
-/**********************************************************************/\r
-/***** Write spans of pixels *****/\r
-/**********************************************************************/\r
-\r
-\r
-static void write_index_span( GLcontext *ctx,\r
- GLuint n, GLint x, GLint y,\r
- const GLuint index[],\r
- const GLubyte mask[] )\r
-{\r
- int i;\r
- y = FLIP(y);\r
-#ifdef UNIVBE\r
- SV_beginPixel();\r
-#endif\r
- for (i=0;i<n;i++,x++) {\r
- if (mask[i]) {\r
-#ifdef UNIVBE\r
- SV_putPixelFast(x,y,current_color);\r
-#else\r
- vga_setcolor( index[i] );\r
- vga_drawpixel( x, y );\r
-#endif\r
- }\r
- }\r
-\r
-#ifdef UNIVBE\r
- SV_endPixel();\r
-#endif\r
-\r
-}\r
-\r
-\r
-\r
-static void write_monoindex_span( GLcontext *ctx,\r
- GLuint n, GLint x, GLint y,\r
- const GLubyte mask[] )\r
-{\r
- int i;\r
- y = FLIP(y);\r
- /* use current color index */\r
- vga_setcolor( DOSMesa->index );\r
-#ifdef UNIVBE\r
- SV_beginPixel();\r
-#endif\r
- for (i=0;i<n;i++,x++) {\r
- if (mask[i]) {\r
-#ifdef UNIVBE\r
- SV_putPixelFast(x,y,current_color);\r
-#else\r
- vga_drawpixel( x, y );\r
-#endif\r
- }\r
- }\r
-#ifdef UNIVBE\r
- SV_endPixel();\r
-#endif\r
-}\r
-\r
-\r
-\r
-static void write_color_span( GLcontext *ctx,\r
- GLuint n, GLint x, GLint y,\r
- const GLubyte red[], const GLubyte green[],\r
- const GLubyte blue[], const GLubyte alpha[],\r
- const GLubyte mask[] )\r
-{\r
- int i;\r
- y=FLIP(y);\r
-#ifdef UNIVBE\r
- SV_beginPixel();\r
-#endif\r
- if (mask) {\r
- /* draw some pixels */\r
- for (i=0; i<n; i++, x++) {\r
- if (mask[i]) {\r
-#ifdef UNIVBE\r
- SV_putPixelFast(x,y,SV_rgbColor(red[i], green[i], blue[i]) );\r
-#else\r
- vga_setrgbcolor( red[i], green[i], blue[i] );\r
- vga_drawpixel( x, y );\r
-#endif\r
- }\r
- }\r
- }\r
- else {\r
- /* draw all pixels */\r
- for (i=0; i<n; i++, x++) {\r
-#ifdef UNIVBE\r
- SV_putPixelFast(x,y,SV_rgbColor(red[i], green[i], blue[i]) );\r
-#else\r
- vga_setrgbcolor( red[i], green[i], blue[i] );\r
- vga_drawpixel( x, y );\r
-#endif\r
- }\r
- }\r
-#ifdef UNIVBE\r
- SV_endPixel();\r
-#endif\r
-}\r
-\r
-\r
-\r
-static void write_monocolor_span( GLcontext *ctx,\r
- GLuint n, GLint x, GLint y,\r
- const GLubyte mask[])\r
-{\r
- int i;\r
- y=FLIP(y);\r
-#ifdef UNIVBE\r
- SV_beginPixel();\r
-#endif\r
- /* use current rgb color */\r
- vga_setrgbcolor( DOSMesa->red, DOSMesa->green, DOSMesa->blue );\r
- for (i=0; i<n; i++, x++) {\r
- if (mask[i]) {\r
-#ifdef UNIVBE\r
- SV_putPixelFast(x,y,current_color);\r
-#else\r
- vga_drawpixel( x, y );\r
-#endif\r
- }\r
- }\r
-#ifdef UNIVBE\r
- SV_endPixel();\r
-#endif\r
-}\r
-\r
-\r
-\r
-/**********************************************************************/\r
-/***** Read spans of pixels *****/\r
-/**********************************************************************/\r
-\r
-\r
-static void read_index_span( GLcontext *ctx,\r
- GLuint n, GLint x, GLint y, GLuint index[])\r
-{\r
- int i;\r
- y = FLIP(y);\r
- for (i=0; i<n; i++,x++) {\r
- index[i] = vga_getpixel( x, y );\r
- }\r
-}\r
-\r
-\r
-\r
-static void read_color_span( GLcontext *ctx,\r
- GLuint n, GLint x, GLint y,\r
- GLubyte red[], GLubyte green[],\r
- GLubyte blue[], GLubyte alpha[] )\r
-{\r
- int i;\r
- for (i=0; i<n; i++, x++) {\r
- /* TODO */\r
- }\r
-}\r
-\r
-\r
-\r
-/**********************************************************************/\r
-/***** Write arrays of pixels *****/\r
-/**********************************************************************/\r
-\r
-\r
-static void write_index_pixels( GLcontext *ctx,\r
- GLuint n, const GLint x[], const GLint y[],\r
- const GLuint index[], const GLubyte mask[] )\r
-{\r
- int i;\r
-#ifdef UNIVBE\r
- SV_beginPixel();\r
-#endif\r
- for (i=0; i<n; i++) {\r
- if (mask[i]) {\r
-#ifdef UNIVBE\r
- SV_putPixelFast(x[i], FLIP(y[i]), index[i] );\r
-#else\r
- vga_setcolor( index[i] );\r
- vga_drawpixel( x[i], FLIP(y[i]) );\r
-#endif\r
- }\r
- }\r
-#ifdef UNIVBE\r
- SV_endPixel();\r
-#endif\r
-}\r
-\r
-\r
-\r
-static void write_monoindex_pixels( GLcontext *ctx,\r
- GLuint n,\r
- const GLint x[], const GLint y[],\r
- const GLubyte mask[] )\r
-{\r
- int i;\r
- /* use current color index */\r
- vga_setcolor( DOSMesa->index );\r
-#ifdef UNIVBE\r
- SV_beginPixel();\r
-#endif\r
- for (i=0; i<n; i++) {\r
- if (mask[i]) {\r
-#ifdef UNIVBE\r
- SV_putPixelFast(x[i], FLIP(y[i]), DOSMesa->index);\r
-#else\r
- vga_drawpixel( x[i], FLIP(y[i]) );\r
-#endif\r
- }\r
- }\r
-#ifdef UNIVBE\r
- SV_endPixel();\r
-#endif\r
-}\r
-\r
-\r
-\r
-static void write_color_pixels( GLcontext *ctx,\r
- GLuint n, const GLint x[], const GLint y[],\r
- const GLubyte r[], const GLubyte g[],\r
- const GLubyte b[], const GLubyte a[],\r
- const GLubyte mask[] )\r
-{\r
- int i;\r
-#ifdef UNIVBE\r
- SV_beginPixel();\r
-#endif\r
- for (i=0; i<n; i++) {\r
- if (mask[i]) {\r
-#ifdef UNIVBE\r
- SV_putPixelFast(x[i], FLIP(y[i]), SV_rgbColor(r[i], g[i], b[i]) );\r
-#else\r
- vga_setrgbcolor( r[i], g[i], b[i] );\r
- vga_drawpixel( x[i], FLIP(y[i]) );\r
-#endif\r
- }\r
- }\r
-#ifdef UNIVBE\r
- SV_endPixel();\r
-#endif\r
-}\r
-\r
-static void write_monocolor_pixels( GLcontext *ctx,\r
- GLuint n,\r
- const GLint x[], const GLint y[],\r
- const GLubyte mask[] )\r
-{\r
- int i;\r
- /* use current rgb color */\r
- vga_setrgbcolor( DOSMesa->red, DOSMesa->green, DOSMesa->blue );\r
-#ifdef UNIVBE\r
- SV_beginPixel();\r
-#endif\r
- for (i=0; i<n; i++) {\r
- if (mask[i]) {\r
-#ifdef UNIVBE\r
- SV_putPixelFast(x[i], FLIP(y[i]), current_color );\r
-#else\r
- vga_drawpixel( x[i], FLIP(y[i]) );\r
-#endif\r
- }\r
- }\r
-#ifdef UNIVBE\r
- SV_endPixel();\r
-#endif\r
-}\r
-\r
-/**********************************************************************/\r
-/***** Read arrays of pixels *****/\r
-/**********************************************************************/\r
-\r
-/* Read an array of color index pixels. */\r
-static void read_index_pixels( GLcontext *ctx,\r
- GLuint n, const GLint x[], const GLint y[],\r
- GLuint index[], const GLubyte mask[] )\r
-{\r
- int i;\r
- for (i=0; i<n; i++) {\r
- index[i] = vga_getpixel( x[i], FLIP(y[i]) );\r
- }\r
-}\r
-\r
-\r
-\r
-static void read_color_pixels( GLcontext *ctx,\r
- GLuint n, const GLint x[], const GLint y[],\r
- GLubyte red[], GLubyte green[],\r
- GLubyte blue[], GLubyte alpha[],\r
- const GLubyte mask[] )\r
-{\r
- /* TODO */\r
-}\r
-\r
-static void DOSmesa_setup_DD_pointers( GLcontext *ctx )\r
-{\r
- /* Initialize all the pointers in the DD struct. Do this whenever */\r
- /* a new context is made current or we change buffers via set_buffer! */\r
-\r
- ctx->Driver.UpdateState = DOSmesa_setup_DD_pointers;\r
-\r
- ctx->Driver.ClearIndex = clear_index;\r
- ctx->Driver.ClearColor = clear_color;\r
- ctx->Driver.Clear = clear;\r
-\r
- ctx->Driver.Index = set_index;\r
- ctx->Driver.Color = set_color;\r
-\r
- ctx->Driver.SetBuffer = set_buffer;\r
- ctx->Driver.GetBufferSize = get_buffer_size;\r
-\r
- ctx->Driver.PointsFunc = choose_points_function();\r
- ctx->Driver.LineFunc = choose_line_function();\r
- ctx->Driver.TriangleFunc = choose_triangle_function();\r
-\r
-\r
- /* Pixel/span writing functions: */\r
- /* TODO: use different funcs for 8, 16, 32-bit depths */\r
- ctx->Driver.WriteColorSpan = write_color_span;\r
- ctx->Driver.WriteMonocolorSpan = write_monocolor_span;\r
- ctx->Driver.WriteColorPixels = write_color_pixels;\r
- ctx->Driver.WriteMonocolorPixels = write_monocolor_pixels;\r
- ctx->Driver.WriteIndexSpan = write_index_span;\r
- ctx->Driver.WriteMonoindexSpan = write_monoindex_span;\r
- ctx->Driver.WriteIndexPixels = write_index_pixels;\r
- ctx->Driver.WriteMonoindexPixels = write_monoindex_pixels;\r
-\r
- /* Pixel/span reading functions: */\r
- /* TODO: use different funcs for 8, 16, 32-bit depths */\r
- ctx->Driver.ReadIndexSpan = read_index_span;\r
- ctx->Driver.ReadColorSpan = read_color_span;\r
- ctx->Driver.ReadIndexPixels = read_index_pixels;\r
- ctx->Driver.ReadColorPixels = read_color_pixels;\r
-}\r
-\r
-/*\r
- * Create a new VGA/Mesa context and return a handle to it.\r
- */\r
-DOSMesaContext DOSMesaCreateContext( void )\r
-{\r
- DOSMesaContext ctx;\r
- GLboolean rgb_flag;\r
- GLfloat redscale, greenscale, bluescale, alphascale;\r
- GLboolean db_flag = GL_FALSE;\r
- GLboolean alpha_flag = GL_FALSE;\r
- int colors;\r
- GLint index_bits;\r
- GLint redbits, greenbits, bluebits, alphabits;\r
-\r
-#if !defined(UNIVBE) && !defined(GLIDE) && !defined(MGL)\r
- video_buffer = (unsigned char *) malloc( vga_getxdim() * vga_getydim() );\r
-\r
- memset(video_buffer,0, vga_getxdim() * vga_getydim() );\r
-\r
- memset(rgbtable,0,sizeof( rgbtable ) );\r
-#endif\r
-\r
-#if defined( DJGPP ) && !defined(UNIVBE) && !defined(GLIDE)\r
- dos_seg = _go32_conventional_mem_selector();\r
-#endif\r
-\r
- /* determine if we're in RGB or color index mode */\r
- colors = vga_getcolors();\r
- if (colors==32768) {\r
- rgb_flag = GL_TRUE;\r
- redscale = greenscale = bluescale = alphascale = 255.0;\r
- redbits = greenbits = bluebits = 8;\r
- alphabits = 0;\r
- index_bits = 0;\r
- }\r
- else if (colors==256) {\r
- rgb_flag = GL_FALSE;\r
- redscale = greenscale = bluescale = alphascale = 0.0;\r
- redbits = greenbits = bluebits = alphabits = 0;\r
- index_bits = 8;\r
- }\r
- else {\r
- restore_video_mode();\r
- fprintf(stderr,"[%d] >16 bit color not implemented yet!\n",colors);\r
- return NULL;\r
- }\r
-\r
- ctx = (DOSMesaContext) calloc( 1, sizeof(struct DOSmesa_context) );\r
- if (!ctx) {\r
- return NULL;\r
- }\r
-\r
- ctx->gl_vis = _mesa_create_visual( rgb_flag,\r
- db_flag,\r
- GL_FALSE, /* stereo */\r
- redbits,\r
- greenbits,\r
- bluebits,\r
- alphabits,\r
- index_bits,\r
- 16, /* depth_size */\r
- 8, /* stencil_size */\r
- 16, 16, 16, 16, /* accum_size */\r
- 1 );
-\r
- ctx->gl_ctx = _mesa_create_context( ctx->gl_vis,\r
- NULL, /* share list context */\r
- (void *) ctx\r
- );\r
-\r
- ctx->gl_buffer = _mesa_create_framebuffer( ctx->gl_vis );\r
-\r
- ctx->index = 1;\r
- ctx->red = ctx->green = ctx->blue = 255;\r
-\r
- ctx->width = ctx->height = 0; /* temporary until first "make-current" */\r
-\r
- return ctx;\r
-}\r
-\r
-/*\r
- * Destroy the given VGA/Mesa context.\r
- */\r
-void DOSMesaDestroyContext( DOSMesaContext ctx )\r
-{\r
- if (ctx) {\r
- _mesa_destroy_visual( ctx->gl_vis );\r
- _mesa_destroy_context( ctx->gl_ctx );\r
- _mesa_destroy_framebuffer( ctx->gl_buffer );\r
- free( ctx );\r
- if (ctx==DOSMesa) {\r
- DOSMesa = NULL;\r
- }\r
- }\r
-}\r
-\r
-\r
-\r
-/*\r
- * Make the specified VGA/Mesa context the current one.\r
- */\r
-void DOSMesaMakeCurrent( DOSMesaContext ctx )\r
-{\r
- DOSMesa = ctx;\r
- _mesa_make_current( ctx->gl_ctx, ctx->gl_buffer );\r
- DOSmesa_setup_DD_pointers( ctx->gl_ctx );\r
-\r
- if (ctx->width==0 || ctx->height==0) {\r
- /* setup initial viewport */\r
- ctx->width = vga_getxdim();\r
- ctx->height = vga_getydim();\r
- _mesa_set_viewport( ctx->gl_ctx, 0, 0, ctx->width, ctx->height );\r
- }\r
-}\r
-\r
-\r
-\r
-/*\r
- * Return a handle to the current VGA/Mesa context.\r
- */\r
-DOSMesaContext DOSMesaGetCurrentContext( void )\r
-{\r
- return DOSMesa;\r
-}\r
-\r
-\r
-/*\r
- * Swap front/back buffers for current context if double buffered.\r
- */\r
-void DOSMesaSwapBuffers( void )\r
-{\r
-#if !defined(UNIVBE)\r
-/* Assume double buffering is available if in UNIVBE,\r
- if it isn`t its taken care of anyway */\r
-// if (DOSMesa->gl_vis->DBflag)\r
-#endif\r
- {\r
- vga_flip();\r
- }\r
-}\r
-\r
-\r
-#else\r
-\r
-/*\r
- * Need this to provide at least one external definition when DOS is\r
- * not defined on the compiler command line.\r
- */\r
-\r
-int gl_DOS_dummy_function(void)\r
-{\r
- return 0;\r
-}\r
-\r
-#endif /*DOS*/\r
-\r