]> 4ch.mooo.com Git - 16.git/blobdiff - 16/v2/source/verge/ENGINE/MODEX.C
renamed: ptmp0.pcx -> data/ptmp0.pcx
[16.git] / 16 / v2 / source / verge / ENGINE / MODEX.C
diff --git a/16/v2/source/verge/ENGINE/MODEX.C b/16/v2/source/verge/ENGINE/MODEX.C
deleted file mode 100644 (file)
index 6247f8e..0000000
+++ /dev/null
@@ -1,1055 +0,0 @@
-/*\r
-Copyright (C) 1998 BJ Eirich (aka vecna)\r
-This program is free software; you can redistribute it and/or\r
-modify it under the terms of the GNU General Public License\r
-as published by the Free Software Foundation; either version 2\r
-of the License, or (at your option) any later version.\r
-This program 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.\r
-See the GNU General Public Lic\r
-See the GNU General Public License for more details.\r
-You should have received a copy of the GNU General Public License\r
-along with this program; if not, write to the Free Software\r
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\r
-*/\r
-\r
-\r
-#include <dpmi.h>\r
-#include <sys\nearptr.h>\r
-#include "verge.h"\r
-\r
-// ================================= Data ====================================\r
-\r
-#define SEQU_ADDR               0x3c4\r
-#define CRTC_ADDR               0x3d4\r
-#define MISC_OUTPUT             0x3c2\r
-\r
-byte *screenbase;                   // ptr to A000:0000\r
-int endcol,nextl;                   // end column number thingy | next line\r
-int winofs;\r
-\r
-// ================================= Code ====================================\r
-\r
-void ModeXSetMode(int mode)\r
-{\r
-  REGISTERS r;\r
-  SET_AX(r, mode);\r
-  INTERRUPT(0x10, r);\r
-}\r
-\r
-void plane(byte p)\r
-{\r
-  int hi=1<<p;\r
-  outpw(0x03c4, (hi<<8)|0x02);\r
-}\r
-\r
-int ModeXShutdown()\r
-{\r
-  ModeXSetMode(0x3);\r
-  vfree(screen);\r
-  return 0;\r
-}\r
-\r
-void clearScreen()\r
-{\r
-   // set write to ALL PLANES simultaneously for extra-quick clears.\r
-   asm("movw $0x3c4, %%dx              \n\t"\r
-       "movw $0x0f02, %%ax             \n\t"\r
-       "outw %%ax, %%dx                \n\t"\r
-       "movl _screenbase, %%edi        \n\t"\r
-       "movl $0, %%eax                 \n\t"\r
-       "movl $11264, %%ecx             \n\t"\r
-       "rep                            \n\t"\r
-       "stosl                          \n\t"\r
-       :\r
-       :\r
-       : "eax","edx","edi","ecx","cc" );\r
-}\r
-\r
-void SetView(word offset)\r
-{\r
-  while (inportb(0x3da) & 1);\r
-\r
-  _disable();\r
-\r
-  outportb(0x3d4, (offset >> 8) | 0x0c);\r
-  outportb(0x3d4, (offset & 0xff) | 0x0d);\r
-\r
-  _enable();\r
-}\r
-\r
-int ModeXShowPage()\r
-{\r
-  byte *s,*d;\r
-  int x,y,k;\r
-  int sx2;\r
-  int b;\r
-\r
-  RenderGUI();\r
-  cpubyte=PFLIP;\r
-\r
-  //s=screen+(16*tsx)+16;\r
-  b=(16*tsx)+16;\r
-  d=screenbase;\r
-  sx2=sx>>2;\r
-\r
-  //while (!(inp(986) & 8));\r
-\r
-  for (y=0; y<sy; ++y,d+=sx2)\r
-  {\r
-    s=screen+(y*tsx)+b;\r
-    for (k=0; k<4; k++,s-=sx)\r
-    {\r
-      plane(k);\r
-      for (x=0; x<sx2; x++,s+=4)\r
-        d[x]=s[k];\r
-    }\r
-  }\r
-\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXCopySprite(int x, int y, int width, int height, byte *src)\r
-{\r
-  cpubyte=RENDER;\r
-\r
-  asm("movl %3, %%edx                   \n\t"\r
-      "movl %4, %%esi                   \n\t"\r
-"csl0:                                  \n\t"\r
-      "movl %1, %%eax                   \n\t"\r
-      "imul _tsx, %%eax                 \n\t"\r
-      "addl %0, %%eax                   \n\t"\r
-      "addl _screen, %%eax              \n\t"\r
-      "movl %%eax, %%edi                \n\t"\r
-      "movl %2, %%ecx                   \n\t"\r
-      "shrl $2, %%ecx                   \n\t"\r
-      "repz                             \n\t"\r
-      "movsl                            \n\t"\r
-      "incl %1                          \n\t"\r
-      "decl %%edx                       \n\t"\r
-      "jnz csl0                         \n\t"\r
-      :\r
-      : "m" (x), "m" (y), "m" (width), "m" (height), "m" (src)\r
-      : "eax","edx","esi","edi","ecx","cc" );\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXTCopySprite(int x, int y, int width, int height, byte *src)\r
-{\r
-  cpubyte=RENDER;\r
-\r
-  asm("movl %3, %%ecx                   \n\t"\r
-      "movl %4, %%esi                   \n\t"\r
-"tcsl0:                                 \n\t"\r
-      "movl %1, %%eax                   \n\t"\r
-      "imul _tsx, %%eax                 \n\t"\r
-      "addl %0, %%eax                   \n\t"\r
-      "addl _screen, %%eax              \n\t"\r
-      "movl %%eax, %%edi                \n\t"\r
-      "movl %2, %%edx                   \n\t"\r
-"drawloop:                              \n\t"\r
-      "lodsb                            \n\t"\r
-      "orb %%al, %%al                   \n\t"\r
-      "jz nodraw                        \n\t"\r
-      "stosb                            \n\t"\r
-      "decl %%edx                       \n\t"\r
-      "jz endline                       \n\t"\r
-      "jmp drawloop                     \n\t"\r
-"nodraw:                                \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "decl %%edx                       \n\t"\r
-      "jnz drawloop                     \n\t"\r
-"endline:                               \n\t"\r
-      "incl %1                          \n\t"\r
-      "decl %%ecx                       \n\t"\r
-      "jnz tcsl0                        \n\t"\r
-      :\r
-      : "m" (x), "m" (y), "m" (width), "m" (height), "m" (src)\r
-      : "eax","edx","esi","edi","ecx","cc" );\r
-\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXCopyTile(int x, int y, byte *spr)\r
-{\r
-  cpubyte=RENDER;\r
-\r
-  asm("movl $16, %%ecx                  \n\t"\r
-      "movl %2, %%esi                   \n\t"\r
-      "movl %1, %%edi                   \n\t"\r
-      "imul _tsx, %%edi                 \n\t"\r
-      "addl %0, %%edi                   \n\t"\r
-      "addl _screen, %%edi              \n\t"\r
-" ctl0:                                 \n\t"\r
-      "movl (%%edi), %%eax              \n\t"\r
-      "andl $0, %%eax                   \n\t"\r
-      "orl  (%%esi), %%eax              \n\t"\r
-      "movl %%eax, (%%edi)              \n\t"\r
-      "movl 4(%%edi), %%eax             \n\t"\r
-      "andl $0, %%eax                   \n\t"\r
-      "orl  4(%%esi), %%eax             \n\t"\r
-      "movl %%eax, 4(%%edi)             \n\t"\r
-      "movl 8(%%edi), %%eax             \n\t"\r
-      "andl $0, %%eax                   \n\t"\r
-      "orl  8(%%esi), %%eax             \n\t"\r
-      "movl %%eax, 8(%%edi)             \n\t"\r
-      "movl 12(%%edi), %%eax            \n\t"\r
-      "andl $0, %%eax                   \n\t"\r
-      "orl  12(%%esi), %%eax            \n\t"\r
-      "movl %%eax, 12(%%edi)            \n\t"\r
-      "addl $16, %%esi                  \n\t"\r
-      "addl _tsx, %%edi                 \n\t"\r
-      "decl %%ecx                       \n\t"\r
-      "jnz ctl0                         \n\t"\r
-      :\r
-      : "m" (x), "m" (y), "m" (spr)\r
-      : "eax","ecx","esi","edi","cc" );\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXTCopyTile(int x, int y, byte *spr, byte *matte)\r
-{\r
-  cpubyte=RENDER;\r
-  asm("movl $16, %%ecx                  \n\t"\r
-      "movl %2, %%esi                   \n\t"\r
-      "movl %1, %%edi                   \n\t"\r
-      "imul _tsx, %%edi                 \n\t"\r
-      "addl %0, %%edi                   \n\t"\r
-      "addl _screen, %%edi              \n\t"\r
-      "movl %3, %%edx                   \n\t"\r
-"tctl0:                                 \n\t"\r
-      "movl (%%edi), %%eax              \n\t"\r
-      "andl (%%edx), %%eax              \n\t"\r
-      "orl  (%%esi), %%eax              \n\t"\r
-      "movl %%eax, (%%edi)              \n\t"\r
-      "movl 4(%%edi), %%eax             \n\t"\r
-      "andl 4(%%edx), %%eax             \n\t"\r
-      "orl  4(%%esi), %%eax             \n\t"\r
-      "movl %%eax, 4(%%edi)             \n\t"\r
-      "movl 8(%%edi), %%eax             \n\t"\r
-      "andl 8(%%edx), %%eax             \n\t"\r
-      "orl  8(%%esi), %%eax             \n\t"\r
-      "movl %%eax, 8(%%edi)             \n\t"\r
-      "movl 12(%%edi), %%eax            \n\t"\r
-      "andl 12(%%edx), %%eax            \n\t"\r
-      "orl  12(%%esi), %%eax            \n\t"\r
-      "movl %%eax, 12(%%edi)            \n\t"\r
-      "addl $16, %%esi                  \n\t"\r
-      "addl _tsx, %%edi                 \n\t"\r
-      "addl $16, %%edx                  \n\t"\r
-      "decl %%ecx                       \n\t"\r
-      "jnz tctl0                        \n\t"\r
-      :\r
-      : "m" (x), "m" (y), "m" (spr), "m" (matte)\r
-      : "eax","ecx","edx","esi","edi","cc" );\r
-\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXCCopySprite(int x,int y,int width,int height,byte *src)\r
-{\r
-  byte *s,*d;\r
-  int xl,yl,xs,ys;\r
-  int cx1=0, cy1=0, cx2=tsx-1, cy2=tsy-1;\r
-\r
-  cpubyte=RENDER;\r
-\r
-  xl=width;\r
-  yl=height;\r
-  xs=ys=0;\r
-\r
-  if (x>cx2 || y>cy2 || x+xl<cx1 || y+yl<cy1)\r
-    return 0;\r
-\r
-  if (x+xl > cx2) xl=cx2-x+1;\r
-  if (y+yl > cy2) yl=cy2-y+1;\r
-\r
-  if (x<cx1) { xs=cx1-x; xl-=xs; x=cx1; }\r
-  if (y<cy1) { ys=cy1-y; yl-=ys; y=cy1; }\r
-\r
-  s=src;\r
-  if (xs+ys) s+=(ys*width)+xs;\r
-  d=screen+(y*tsx)+x;\r
-\r
-  for (; yl; yl--)\r
-  {\r
-    memcpy(d,s,xl);\r
-    s+=width;\r
-    d+=tsx;\r
-  }\r
-\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXTCCopySprite(int x,int y,int width,int height,byte *src)\r
-{\r
-  byte *s,*d,c;\r
-  int xl,yl,xs,ys;\r
-  int cx1=0, cy1=0, cx2=tsx-1, cy2=tsy-1;\r
-\r
-  cpubyte=RENDER;\r
-\r
-  xl=width;\r
-  yl=height;\r
-  xs=ys=0;\r
-\r
-  if (x>cx2 || y>cy2 || x+xl<cx1 || y+yl<cy1)\r
-    return 0;\r
-\r
-  if (x+xl > cx2) xl=cx2-x+1;\r
-  if (y+yl > cy2) yl=cy2-y+1;\r
-\r
-  if (x<cx1) { xs=cx1-x; xl-=xs; x=cx1; }\r
-  if (y<cy1) { ys=cy1-y; yl-=ys; y=cy1; }\r
-\r
-  s=src;\r
-  if (xs+ys) s+=(ys*width)+xs;\r
-  d=screen+(y*tsx)+x;\r
-\r
-  for (; yl; yl--)\r
-  {\r
-    for (x=0; x<xl; x++)\r
-    {\r
-      c=s[x];\r
-      if (c)\r
-        d[x]=c;\r
-    }\r
-    s+=width;\r
-    d+=tsx;\r
-  }\r
-\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXScaleSprite(int x, int y, int w, int h, int tw, int th, byte *s)\r
-{ int i,j,xm,ym,xd,yd,sx,sy=0,xs,ys,dys=0;\r
-  unsigned char *d;\r
-\r
-  cpubyte=RENDER;\r
-\r
-  if (!tw || !th) return 0;\r
-  tw += sgn(tw); th += sgn(th);\r
-  xm = abs(tw); ym = abs(th);\r
-  xs = (w<<16)/xm; ys = (h<<16)/ym;\r
-  xd = sgn(tw); yd = sgn(th);\r
-\r
-  if (tw>0 && th>0) dys=tsx-xm;\r
-  else if (tw>0 && th<0) dys=(0-tsx)-xm;\r
-  else if (tw<0 && th>0) dys=tsx+xm;\r
-  else if (tw<0 && th<0) dys=(0-tsx)+xm;\r
-\r
-  d = screen+(y*tsx)+x;\r
-  for (i=0;i<ym;++i) {\r
-    sx=0;\r
-    for (j=0;j<xm;++j) {\r
-      *d=s[(sx>>16)];\r
-      d+=xd;\r
-      sx+=xs;\r
-      }\r
-    d+=dys;\r
-    sy+=ys;\r
-    s+=(sy>>16)*w;\r
-    sy&=0xffff;\r
-    }\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXRenderMAPLine(int x, int y, int yofs, word *map)\r
-{\r
-  cpubyte=RENDER;\r
-  asm("movl %1, %%edi                  \n\t"\r
-      "imul _tsx, %%edi                \n\t"\r
-      "addl %0, %%edi                  \n\t"\r
-      "addl _screen, %%edi             \n\t"\r
-      "movl _tx, %%ebx                 \n\t"\r
-      "incl %%ebx                      \n\t"\r
-      "movl %3, %%ecx                  \n\t"\r
-"tileloop:                             \n\t"\r
-      "movw (%%ecx), %%ax              \n\t"\r
-      "movzwl %%ax, %%edx              \n\t"\r
-      "shll $1, %%edx                  \n\t"\r
-      "addl _tileidx, %%edx            \n\t"\r
-      "movw (%%edx), %%ax              \n\t"\r
-      "movzwl %%ax, %%esi              \n\t"\r
-      "shll $8, %%esi                  \n\t"\r
-      "addl _vsp, %%esi                \n\t"\r
-      "movl %2, %%eax                  \n\t"\r
-      "shll $4, %%eax                  \n\t"\r
-      "addl %%eax, %%esi               \n\t"\r
-      "movl (%%esi), %%eax             \n\t"\r
-      "movl %%eax, (%%edi)             \n\t"\r
-      "movl 4(%%esi), %%eax            \n\t"\r
-      "movl %%eax, 4(%%edi)            \n\t"\r
-      "movl 8(%%esi), %%eax            \n\t"\r
-      "movl %%eax, 8(%%edi)            \n\t"\r
-      "movl 12(%%esi), %%eax           \n\t"\r
-      "movl %%eax, 12(%%edi)           \n\t"\r
-      "addl $16, %%edi                 \n\t"\r
-      "addl $2, %%ecx                  \n\t"\r
-      "decl %%ebx                      \n\t"\r
-      "jnz tileloop                    \n\t"\r
-      :\r
-      : "m" (x), "m" (y), "m" (yofs), "m" (map)\r
-      : "eax","ebx","ecx","edx","esi","edi","cc" );\r
-\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXTRenderMAPLine(int x, int y, int yofs, word *map)\r
-{\r
-  cpubyte=RENDER;\r
-  asm("movl %1, %%edi                  \n\t"\r
-      "imul _tsx, %%edi                \n\t"\r
-      "addl %0, %%edi                  \n\t"\r
-      "addl _screen, %%edi             \n\t"\r
-      "movl _tx, %%ebx                 \n\t"\r
-      "incl %%ebx                      \n\t"\r
-      "movl %3, %%ecx                  \n\t"\r
-"tileloop1:                            \n\t"\r
-      "movw (%%ecx), %%ax              \n\t"\r
-      "movzwl %%ax, %%edx              \n\t"\r
-      "shll $1, %%edx                  \n\t"\r
-      "addl _tileidx, %%edx            \n\t"\r
-      "movw (%%edx), %%ax              \n\t"\r
-      "orw %%ax, %%ax                  \n\t"\r
-      "jz next1                        \n\t"\r
-      "movzwl %%ax, %%esi              \n\t"\r
-      "shll $8, %%esi                  \n\t"\r
-      "movl %%esi, %%edx               \n\t"\r
-      "addl _vspmask, %%edx            \n\t"\r
-      "addl _vsp, %%esi                \n\t"\r
-      "movl %2, %%eax                  \n\t"\r
-      "shll $4, %%eax                  \n\t"\r
-      "addl %%eax, %%esi               \n\t"\r
-      "addl %%eax, %%edx               \n\t"\r
-      "movl (%%edi), %%eax             \n\t"\r
-      "andl (%%edx), %%eax             \n\t"\r
-      "orl  (%%esi), %%eax             \n\t"\r
-      "movl %%eax, (%%edi)             \n\t"\r
-      "movl 4(%%edi), %%eax            \n\t"\r
-      "andl 4(%%edx), %%eax            \n\t"\r
-      "orl  4(%%esi), %%eax            \n\t"\r
-      "movl %%eax, 4(%%edi)            \n\t"\r
-      "movl 8(%%edi), %%eax            \n\t"\r
-      "andl 8(%%edx), %%eax            \n\t"\r
-      "orl  8(%%esi), %%eax            \n\t"\r
-      "movl %%eax, 8(%%edi)            \n\t"\r
-      "movl 12(%%edi), %%eax           \n\t"\r
-      "andl 12(%%edx), %%eax           \n\t"\r
-      "orl  12(%%esi), %%eax           \n\t"\r
-      "movl %%eax, 12(%%edi)           \n\t"\r
-"next1:                                \n\t"\r
-      "addl $16, %%edi                 \n\t"\r
-      "addl $2, %%ecx                  \n\t"\r
-      "decl %%ebx                      \n\t"\r
-      "jnz tileloop1                   \n\t"\r
-      :\r
-      : "m" (x), "m" (y), "m" (yofs), "m" (map)\r
-      : "eax","ebx","ecx","edx","esi","edi","cc" );\r
-\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXColorField(int x, int y, byte c)\r
-{\r
-  cpubyte=RENDER;\r
-  asm("movl %1, %%eax                   \n\t"\r
-      "imul _tsx, %%eax                 \n\t"\r
-      "addl %0, %%eax                   \n\t"\r
-      "addl _screen, %%eax              \n\t"\r
-      "movl %%eax, %%edi                \n\t"\r
-      "movl $8, %%ecx                   \n\t"\r
-      "movb %2, %%al                    \n\t"\r
-"lineloop1:                             \n\t"\r
-      "stosb                            \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "stosb                            \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "stosb                            \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "stosb                            \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "stosb                            \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "stosb                            \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "stosb                            \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "stosb                            \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "addl _sx, %%edi                  \n\t"\r
-      "addl $16, %%edi                  \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "stosb                            \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "stosb                            \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "stosb                            \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "stosb                            \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "stosb                            \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "stosb                            \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "stosb                            \n\t"\r
-      "incl %%edi                       \n\t"\r
-      "stosb                            \n\t"\r
-      "addl _sx, %%edi                  \n\t"\r
-      "addl $16, %%edi                  \n\t"\r
-      "decl %%ecx                       \n\t"\r
-      "jnz lineloop1                    \n\t"\r
-      :\r
-      : "m" (x), "m" (y), "m" (c)\r
-      : "eax","edi","ecx","cc" );\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXClearScreen()\r
-{\r
-  cpubyte=RENDER;\r
-  memset(screen+(tsx*16)+16,0,(tsx*sy));\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXPutPixel(int x, int y, int color)\r
-{\r
-  cpubyte=RENDER;\r
-\r
-  if (x<cx1 || y<cy1 || x>cx2 || y>cy2)\r
-  {\r
-    cpubyte=ETC;\r
-    return 0;\r
-  }\r
-\r
-  x+=16;\r
-  y+=16;\r
-\r
-  screen[(y*tsx)+x]=color;\r
-\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXGetPixel(int x, int y)\r
-{\r
-  cpubyte=RENDER;\r
-\r
-  if (x<cx1 || y<cy1 || x>cx2 || y>cy2)\r
-  {\r
-    cpubyte=ETC;\r
-    return 0;\r
-  }\r
-\r
-  x+=16;\r
-  y+=16;\r
-\r
-  cpubyte=ETC;\r
-  return screen[(y*tsx)+x];\r
-}\r
-\r
-int ModeXHLine(int x, int y, int x2, int color)\r
-{ byte *d;\r
-  int width;\r
-\r
-  cpubyte=RENDER;\r
-\r
-  // swap?\r
-  if (x2<x) { int t=x2; x=x2; x2=t; }\r
-\r
-  width=x2-x+1;\r
-  if (x>cx2 || y>cy2 || x+width<cx1 || y<cy1)\r
-    return 0;\r
-\r
-  if (x+width > cx2) width=cx2-x+1;\r
-  if (x<cx1) { width-=(cx1-x); x=cx1; }\r
-\r
-  x+=16;\r
-  y+=16;\r
-  x2+=16;\r
-\r
-  d=screen+(y*tsx)+x;\r
-  memset(d,color,width);\r
-\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXVLine(int x, int y, int y2, int color)\r
-{ byte *d;\r
-  int height;\r
-\r
-  cpubyte=RENDER;\r
-\r
-  // swap?\r
-  if (y2<y) { int t=y2; x=y2; y2=t; }\r
-\r
-  height=y2-y+1;\r
-  if (x>cx2 || y>cy2 || x<cx1 || y+height<cy1)\r
-  {\r
-    cpubyte=ETC;\r
-    return 0;\r
-  }\r
-\r
-  if (y+height > cy2) height=cy2-y+1;\r
-  if (y<cy1) { height-=(cy1-y); y=cy1; }\r
-\r
-  x+=16;\r
-  y+=16;\r
-  y2+=16;\r
-\r
-  d=screen+(y*tsx)+x;\r
-  for (; height; height--)\r
-  {\r
-    *d=color;\r
-    d+=tsx;\r
-  }\r
-\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXLine(int x1, int y1, int x2, int y2, int color)\r
-{\r
-  short i,xc,yc,er,n,m,xi,yi,xcxi,ycyi,xcyi;\r
-  unsigned dcy,dcx;\r
-\r
-  cpubyte=RENDER;\r
-\r
-  // check to see if the line is completly clipped off\r
-  if ((x1<cx1 && x2<cx1) || (x1>cx2 && x2>cx2)\r
-  || (y1<cy1 && y2<cy1) || (y1>cy2 && y2>cy2))\r
-  {\r
-    cpubyte=ETC;\r
-    return 0;\r
-  }\r
-\r
-  if (x1>x2)\r
-  {\r
-    i=x1; x1=x2; x2=i;\r
-    i=y1; y1=y2; y2=i;\r
-  }\r
-\r
-  // clip the left side\r
-  if (x1<cx1)\r
-  { int myy=(y2-y1);\r
-    int mxx=(x2-x1),b;\r
-    if (!mxx)\r
-    {\r
-      cpubyte=ETC;\r
-      return 0;\r
-    }\r
-    if (myy)\r
-    {\r
-      b=y1-(y2-y1)*x1/mxx;\r
-      y1=myy*cx1/mxx+b;\r
-      x1=cx1;\r
-    }\r
-    else x1=cx1;\r
-  }\r
-\r
-  // clip the right side\r
-  if (x2>cx2)\r
-  { int myy=(y2-y1);\r
-    int mxx=(x2-x1),b;\r
-    if (!mxx)\r
-    {\r
-      cpubyte=ETC;\r
-      return 0;\r
-    }\r
-    if (myy)\r
-    {\r
-      b=y1-(y2-y1)*x1/mxx;\r
-      y2=myy*cx2/mxx+b;\r
-      x2=cx2;\r
-    }\r
-    else x2=cx2;\r
-  }\r
-\r
-  if (y1>y2)\r
-  {\r
-    i=x1; x1=x2; x2=i;\r
-    i=y1; y1=y2; y2=i;\r
-  }\r
-\r
-  // clip the bottom\r
-  if (y2>cy2)\r
-  { int mxx=(x2-x1);\r
-    int myy=(y2-y1),b;\r
-    if (!myy)\r
-    {\r
-      cpubyte=ETC;\r
-      return 0;\r
-    }\r
-    if (mxx)\r
-    {\r
-      b=y1-(y2-y1)*x1/mxx;\r
-      x2=(cy2-b)*mxx/myy;\r
-      y2=cy2;\r
-    }\r
-    else y2=cy2;\r
-  }\r
-\r
-  // clip the top\r
-  if (y1<cy1)\r
-  { int mxx=(x2-x1);\r
-    int myy=(y2-y1),b;\r
-    if (!myy)\r
-    {\r
-      cpubyte=ETC;\r
-      return 0;\r
-    }\r
-    if (mxx)\r
-    {\r
-      b=y1-(y2-y1)*x1/mxx;\r
-      x1=(cy1-b)*mxx/myy;\r
-      y1=cy1;\r
-    }\r
-    else y1=cy1;\r
-  }\r
-\r
-  // ???\r
-  // see if it got cliped into the box, out out\r
-  if (x1<cx1 || x2<cx1 || x1>cx2 || x2>cx2 || y1<cy1 || y2 <cy1 || y1>cy2 || y2>cy2)\r
-  {\r
-    cpubyte=ETC;\r
-    return 0;\r
-  }\r
-\r
-  if (x1>x2)\r
-  { xc=x2; xi=x1; }\r
-  else { xi=x2; xc=x1; }\r
-\r
-  x1+=16;y1+=16; // aen; adjust these here??\r
-  x2+=16;y2+=16;\r
-\r
-  // assume y1<=y2 from above swap operation\r
-  yi=y2; yc=y1;\r
-\r
-  dcx=x1; dcy=y1;\r
-  xc=(x2-x1); yc=(y2-y1);\r
-  if (xc<0) xi=-1; else xi=1;\r
-  if (yc<0) yi=-1; else yi=1;\r
-  n=abs(xc); m=abs(yc);\r
-  ycyi=abs(2*yc*xi);\r
-  er=0;\r
-\r
-  if (n>m)\r
-  {\r
-    xcxi=abs(2*xc*xi);\r
-    for (i=0;i<=n;i++)\r
-    {\r
-      screen[(dcy*tsx)+dcx]=color;\r
-      if (er>0)\r
-      { dcy+=yi;\r
-        er-=xcxi;\r
-      }\r
-      er+=ycyi;\r
-      dcx+=xi;\r
-    }\r
-  }\r
-  else\r
-  {\r
-    xcyi=abs(2*xc*yi);\r
-    for (i=0;i<=m;i++)\r
-    {\r
-      screen[(dcy*tsx)+dcx]=color;\r
-      if (er>0)\r
-      { dcx+=xi;\r
-        er-=ycyi;\r
-      }\r
-      er+=xcyi;\r
-      dcy+=yi;\r
-    }\r
-  }\r
-\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXCircle(int x, int y, int radius, int color)\r
-{ int cx=0;\r
-  int cy=radius;\r
-  int df=1-radius;\r
-  int d_e=3;\r
-  int d_se=-2*radius+5;\r
-\r
-  cpubyte=RENDER;\r
-\r
-  do {\r
-    ModeXPutPixel(x+cx,y+cy,color);\r
-    if (cx) ModeXPutPixel(x-cx,y+cy,color);\r
-    if (cy) ModeXPutPixel(x+cx,y-cy,color);\r
-    if ((cx) && (cy)) ModeXPutPixel(x-cx,y-cy,color);\r
-\r
-    if (cx != cy)\r
-    {\r
-      ModeXPutPixel(x+cy,y+cx,color);\r
-      if (cx) ModeXPutPixel(x+cy,y-cx,color);\r
-      if (cy) ModeXPutPixel(x-cy,y+cx,color);\r
-      if (cx && cy) ModeXPutPixel(x-cy,y-cx,color);\r
-    }\r
-\r
-    if (df<0)\r
-    {\r
-      df+=d_e;\r
-      d_e+=2;\r
-      d_se+=2;\r
-    }\r
-    else\r
-    {\r
-      df+=d_se;\r
-      d_e+=2;\r
-      d_se+=4;\r
-      cy--;\r
-    }\r
-\r
-    cx++;\r
-\r
-  } while (cx <= cy);\r
-\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXCircleFill(int x, int y, int radius, int color)\r
-{ int cx=0;\r
-  int cy=radius;\r
-  int df=1-radius;\r
-  int d_e=3;\r
-  int d_se=-2*radius+5;\r
-\r
-  cpubyte=RENDER;\r
-\r
-  do {\r
-    ModeXHLine(x-cy,y-cx,x+cy,color);\r
-    if (cx) ModeXHLine(x-cy,y+cx,x+cy,color);\r
-\r
-    if (df<0)\r
-    {\r
-      df+=d_e;\r
-      d_e+=2;\r
-      d_se+=2;\r
-    }\r
-    else\r
-    {\r
-      if (cx != cy)\r
-      {\r
-        ModeXHLine(x-cx,y-cy,x+cx,color);\r
-        if (cy) ModeXHLine(x-cx,y+cy,x+cx,color);\r
-      }\r
-\r
-      df+=d_se;\r
-      d_e+=2;\r
-      d_se+=4;\r
-      cy--;\r
-    }\r
-\r
-    cx++;\r
-\r
-  } while (cx <= cy);\r
-\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int ModeXRect(int x, int y, int x2, int y2, int color)\r
-{\r
-  ModeXHLine(x,y,x2,color);\r
-  ModeXHLine(x,y2,x2,color);\r
-  ModeXVLine(x,y+1,y2-1,color);\r
-  ModeXVLine(x2,y+1,y2-1,color);\r
-  return 0;\r
-}\r
-\r
-int ModeXRectFill(int x, int y, int x2, int y2, int color)\r
-{\r
-  cpubyte=RENDER;\r
-\r
-  if (y2<y) { int t=y2; y=y2; y2=t; }\r
-\r
-  for (; y<=y2; y++)\r
-    ModeXHLine(x,y,x2,color);\r
-\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-void Set256x256()\r
-// -- ric: 15/Jun/98 --\r
-// My first attempt at graphics code :)\r
-{\r
-  char in_byte;\r
-\r
-  outportw(SEQU_ADDR, 0x0100);\r
-  outportb(CRTC_ADDR, 0x11);\r
-  in_byte = inportb((CRTC_ADDR+1));\r
-  in_byte = (in_byte && 0x7f);\r
-  outportb((CRTC_ADDR+1), in_byte);\r
-  outportw(SEQU_ADDR, 0x0604);\r
-  outportb(MISC_OUTPUT, 0xe3);\r
-\r
-  outportb(CRTC_ADDR, 0x0); outportb(CRTC_ADDR+1, 0x5f);\r
-  outportb(CRTC_ADDR, 0x1); outportb(CRTC_ADDR+1, 0x3f);\r
-  outportb(CRTC_ADDR, 0x2); outportb(CRTC_ADDR+1, 0x40);\r
-  outportb(CRTC_ADDR, 0x3); outportb(CRTC_ADDR+1, 0x82);\r
-  outportb(CRTC_ADDR, 0x4); outportb(CRTC_ADDR+1, 0x4a);\r
-  outportb(CRTC_ADDR, 0x5); outportb(CRTC_ADDR+1, 0x9a);\r
-  outportb(CRTC_ADDR, 0x6); outportb(CRTC_ADDR+1, 0x23);\r
-  outportb(CRTC_ADDR, 0x7); outportb(CRTC_ADDR+1, 0xb2);\r
-  outportb(CRTC_ADDR, 0x8); outportb(CRTC_ADDR+1, 0x0);\r
-  outportb(CRTC_ADDR, 0x9); outportb(CRTC_ADDR+1, 0x61);\r
-  outportb(CRTC_ADDR, 0x10); outportb(CRTC_ADDR+1, 0xa);\r
-  outportb(CRTC_ADDR, 0x11); outportb(CRTC_ADDR+1, 0xac);\r
-  outportb(CRTC_ADDR, 0x12); outportb(CRTC_ADDR+1, 0xff);\r
-  outportb(CRTC_ADDR, 0x14); outportb(CRTC_ADDR+1, 0x0);\r
-  outportb(CRTC_ADDR, 0x15); outportb(CRTC_ADDR+1, 0x7);\r
-  outportb(CRTC_ADDR, 0x16); outportb(CRTC_ADDR+1, 0x1a);\r
-  outportb(CRTC_ADDR, 0x17); outportb(CRTC_ADDR+1, 0xe3);\r
-  outportb(SEQU_ADDR, 0x1);  outportw(SEQU_ADDR+1, 0x1);\r
-  outportb(0x3ce, 0x5); outportb(0x3cf, 0x40);\r
-  outportb(0x3ce, 0x6); outportb(0x3cf, 0x5);\r
-  inportb(0x3DA);\r
-  outportb(0x3C0, 0x1 | 0x20);\r
-  outportb(0x3C0, 0x41);\r
-  outportb(CRTC_ADDR, 0x13);\r
-  outportb(CRTC_ADDR+1, 0x20);\r
-\r
-  outportw(SEQU_ADDR, 0x0300);\r
-\r
-  sx=256;  sy=256;\r
-  tsx=288; tsy=288;\r
-  tx=17;   ty=16;\r
-  cx1=0;   cy1=0;\r
-  cx2=sx-1;cy2=sy-1;\r
-  endcol=272; nextl=64;\r
-  winofs=4608;\r
-  DriverDesc = "256x256 (ModeX, planar)";\r
-}\r
-\r
-void Set320x240()\r
-{ char in_byte;\r
-\r
-  outportw(SEQU_ADDR, 0x0604);\r
-  outportw(SEQU_ADDR, 0x0110);\r
-  outportb(MISC_OUTPUT, 0xe3);\r
-  outportw(SEQU_ADDR, 0x0300);\r
-  outportb(CRTC_ADDR, 0x11);\r
-  in_byte = inportb((CRTC_ADDR+1));\r
-  in_byte = (in_byte && 0x7f);\r
-  outportb((CRTC_ADDR+1), in_byte);\r
-  outportw(CRTC_ADDR, 0x0d06);\r
-  outportw(CRTC_ADDR, 0x3e07);\r
-  outportw(CRTC_ADDR, 0x4109);\r
-  outportw(CRTC_ADDR, 0xea10);\r
-  outportw(CRTC_ADDR, 0xac11);\r
-  outportw(CRTC_ADDR, 0xdf12);\r
-  outportw(CRTC_ADDR, 0x0014);\r
-  outportw(CRTC_ADDR, 0xe715);\r
-  outportw(CRTC_ADDR, 0x0616);\r
-  outportw(CRTC_ADDR, 0xe317);\r
-\r
-  sx=320;  sy=240;\r
-  tsx=352; tsy=272;\r
-  tx=20;   ty=15;\r
-  cx1=0;   cy1=0;\r
-  cx2=sx-1;cy2=sy-1;\r
-  endcol=336; nextl=80;\r
-  winofs=5632;\r
-  DriverDesc = "320x240 (ModeX, planar)";\r
-}\r
-\r
-void Set360x240()\r
-{ char in_byte;\r
-\r
-  outportw(SEQU_ADDR, 0x0604);\r
-  outportw(SEQU_ADDR, 0x100);\r
-  outportb(MISC_OUTPUT, 0xe7);\r
-  outportw(SEQU_ADDR, 0x300);\r
-  outportb(CRTC_ADDR, 0x11);\r
-  in_byte = inportb((CRTC_ADDR+1));\r
-  in_byte = (in_byte && 0x7f);\r
-  outportb((CRTC_ADDR+1), in_byte);\r
-  outportw(CRTC_ADDR, 0x6b00);\r
-  outportw(CRTC_ADDR, 0x5901);\r
-  outportw(CRTC_ADDR, 0x5a02);\r
-  outportw(CRTC_ADDR, 0x8e03);\r
-  outportw(CRTC_ADDR, 0x5e04);\r
-  outportw(CRTC_ADDR, 0x8a05);\r
-  outportw(CRTC_ADDR, 0x0d06);\r
-  outportw(CRTC_ADDR, 0x3e07);\r
-  outportw(CRTC_ADDR, 0x4109);\r
-  outportw(CRTC_ADDR, 0xea10);\r
-  outportw(CRTC_ADDR, 0xac11);\r
-  outportw(CRTC_ADDR, 0xdf12);\r
-  outportw(CRTC_ADDR, 0x2d13);\r
-  outportw(CRTC_ADDR, 0x0014);\r
-  outportw(CRTC_ADDR, 0xe715);\r
-  outportw(CRTC_ADDR, 0x0616);\r
-  outportw(CRTC_ADDR, 0xe317);\r
-\r
-  sx=360;  sy=240;\r
-  tsx=392; tsy=272;\r
-  tx=23;   ty=15;\r
-  cx1=0;   cy1=0;\r
-  cx2=sx-1;cy2=sy-1;\r
-  endcol=376; nextl=90;\r
-  winofs=6272;\r
-  DriverDesc = "360x240 (ModeX, planar)";\r
-}\r
-\r
-void InitModeX(int res)\r
-{\r
-  ModeXSetMode(0x13);\r
-\r
-  switch (res)\r
-  {\r
-    case 0: Set320x240(); break;\r
-    case 1: Set360x240(); break;\r
-    case 2: Set256x256(); break; /* -- ric: 15/Jun/98 -- */\r
-    default: err("Internal error: unknown ModeX resolution code");\r
-  }\r
-\r
-  screenbase=(char *) 0xA0000+__djgpp_conventional_base;\r
-  screen=(char *) malloc(107648);\r
-  memset(screen,0,107648);\r
-  clearScreen();\r
-\r
-  // Mode successfuly set, now lets set up the driver.\r
-\r
-  ShutdownVideo = ModeXShutdown;\r
-  ShowPage = ModeXShowPage;\r
-  CopySprite = ModeXCopySprite;\r
-  TCopySprite = ModeXTCopySprite;\r
-  CCopySprite = ModeXCCopySprite;\r
-  TCCopySprite = ModeXTCCopySprite;\r
-  CopyTile = ModeXCopyTile;\r
-  TCopyTile = ModeXTCopyTile;\r
-  ScaleSprite = ModeXScaleSprite;\r
-  RenderMAPLine = ModeXRenderMAPLine;\r
-  TRenderMAPLine = ModeXTRenderMAPLine;\r
-  ColorField = ModeXColorField;\r
-  ClearScreen = ModeXClearScreen;\r
-  PutPixel = ModeXPutPixel;\r
-  GetPixel = ModeXGetPixel;\r
-  HLine = ModeXHLine;\r
-  VLine = ModeXVLine;\r
-  Line = ModeXLine;\r
-  Circle = ModeXCircle;\r
-  CircleFill = ModeXCircleFill;\r
-  Rect = ModeXRect;\r
-  RectFill = ModeXRectFill;\r
-}\r