]> 4ch.mooo.com Git - 16.git/blobdiff - 16/v2/source/ENGINE/MODE13H.C
renamed: ptmp0.pcx -> data/ptmp0.pcx
[16.git] / 16 / v2 / source / ENGINE / MODE13H.C
diff --git a/16/v2/source/ENGINE/MODE13H.C b/16/v2/source/ENGINE/MODE13H.C
deleted file mode 100644 (file)
index 2dcbf9c..0000000
+++ /dev/null
@@ -1,881 +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
-#include <dpmi.h>\r
-#include <sys\nearptr.h>\r
-#include "verge.h"\r
-\r
-// ================================= Data ====================================\r
-\r
-byte *screen, *screenx;             // virscr | realscr\r
-\r
-// ================================= Code ====================================\r
-\r
-void SetMode(int mode)\r
-{\r
-  REGISTERS r;\r
-  SET_AX(r, mode);\r
-  INTERRUPT(0x10, r);\r
-}\r
-\r
-int Mode13hShutdown(void)\r
-{\r
-  SetMode(0x3);\r
-  free(screen);\r
-  return 0;\r
-}\r
-\r
-void xShowPage(int startofs)\r
-{\r
-  asm("movl _screen, %%esi              \n\t"\r
-      "addl %0, %%esi                   \n\t"\r
-      "movl _screenx, %%edi             \n\t"\r
-      "movl $200, %%eax                 \n\t"\r
-"lineloop:                              \n\t"\r
-      "movl $80, %%ecx                  \n\t"\r
-      "rep                              \n\t"\r
-      "movsl                            \n\t"\r
-      "addl $32, %%esi                  \n\t"\r
-      "decl %%eax                       \n\t"\r
-      "jnz lineloop                     \n\t"\r
-      :\r
-      : "m" (startofs)\r
-      : "esi", "edi", "cc", "eax", "ecx");\r
-}\r
-\r
-int Mode13hShowPage(void)\r
-{\r
-  RenderGUI();\r
-  cpubyte=PFLIP;\r
-  xShowPage((16*352)+16);\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int Mode13hCopySprite(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 $352, %%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 Mode13hCopyTile(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 $352, %%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 $352, %%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 Mode13hTCopySprite(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 $352, %%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 Mode13hTCopyTile(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 $352, %%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 $352, %%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 Mode13hCCopySprite(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 (ys) s+=(ys*width); // only perform mul if necessary ;)\r
-  if (xs) s+=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 Mode13hTCCopySprite(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 (ys) s+=(ys*width); // only perform mul if necessary ;)\r
-  if (xs) s+=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 Mode13hScaleSprite(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 Mode13hRenderMAPLine(int x, int y, int yofs, word *map)\r
-{\r
-  cpubyte=RENDER;\r
-  asm("movl %1, %%edi                  \n\t"\r
-      "imul $352, %%edi                \n\t"\r
-      "addl %0, %%edi                  \n\t"\r
-      "addl _screen, %%edi             \n\t"\r
-      "movl $22, %%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 Mode13hTRenderMAPLine(int x, int y, int yofs, word *map)\r
-{\r
-  cpubyte=RENDER;\r
-  asm("movl %1, %%edi                  \n\t"\r
-      "imul $352, %%edi                \n\t"\r
-      "addl %0, %%edi                  \n\t"\r
-      "addl _screen, %%edi             \n\t"\r
-      "movl $22, %%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 Mode13hColorField(int x, int y, byte c)\r
-{\r
-  cpubyte=RENDER;\r
-  asm("movl %1, %%eax                   \n\t"\r
-      "imul $352, %%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 $336, %%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 $336, %%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 Mode13hClearScreen()\r
-{\r
-  cpubyte=RENDER;\r
-  memset(screen+(352*16)+16,0,(352*200));\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-int Mode13hPutPixel(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 Mode13hGetPixel(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 Mode13hHLine(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 Mode13hVLine(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 Mode13hLine(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 Mode13hCircle(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
-    Mode13hPutPixel(x+cx,y+cy,color);\r
-    if (cx) Mode13hPutPixel(x-cx,y+cy,color);\r
-    if (cy) Mode13hPutPixel(x+cx,y-cy,color);\r
-    if ((cx) && (cy)) Mode13hPutPixel(x-cx,y-cy,color);\r
-\r
-    if (cx != cy)\r
-    {\r
-      Mode13hPutPixel(x+cy,y+cx,color);\r
-      if (cx) Mode13hPutPixel(x+cy,y-cx,color);\r
-      if (cy) Mode13hPutPixel(x-cy,y+cx,color);\r
-      if (cx && cy) Mode13hPutPixel(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 Mode13hCircleFill(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
-    Mode13hHLine(x-cy,y-cx,x+cy,color);\r
-    if (cx) Mode13hHLine(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
-        Mode13hHLine(x-cx,y-cy,x+cx,color);\r
-        if (cy) Mode13hHLine(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 Mode13hRect(int x, int y, int x2, int y2, int color)\r
-{\r
-  Mode13hHLine(x,y,x2,color);\r
-  Mode13hHLine(x,y2,x2,color);\r
-  Mode13hVLine(x,y+1,y2-1,color);\r
-  Mode13hVLine(x2,y+1,y2-1,color);\r
-  return 0;\r
-}\r
-\r
-int Mode13hRectFill(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
-    Mode13hHLine(x,y,x2,color);\r
-\r
-  cpubyte=ETC;\r
-  return 0;\r
-}\r
-\r
-void InitMode13h(void)\r
-{\r
-  SetMode(0x13);\r
-\r
-  screenx=(byte *) 0xA0000 + __djgpp_conventional_base;\r
-  screen=(byte *) malloc(95744);\r
-  memset(screen, 0, 95744);\r
-\r
-  sx=320;  sy=200;\r
-  tsx=352; tsy=232;\r
-  tx=20;   ty=13;\r
-  cx1=0;   cy1=0;\r
-  cx2=sx-1;cy2=sy-1;\r
-\r
-  // Mode successfuly set, now lets set up the driver.\r
-  ShutdownVideo = Mode13hShutdown;\r
-  ShowPage = Mode13hShowPage;\r
-  CopySprite = Mode13hCopySprite;\r
-  TCopySprite = Mode13hTCopySprite;\r
-  CCopySprite = Mode13hCCopySprite;\r
-  TCCopySprite = Mode13hTCCopySprite;\r
-  CopyTile = Mode13hCopyTile;\r
-  TCopyTile = Mode13hTCopyTile;\r
-  ScaleSprite = Mode13hScaleSprite;\r
-  RenderMAPLine = Mode13hRenderMAPLine;\r
-  TRenderMAPLine = Mode13hTRenderMAPLine;\r
-  ColorField = Mode13hColorField;\r
-  ClearScreen = Mode13hClearScreen;\r
-  PutPixel = Mode13hPutPixel;\r
-  GetPixel = Mode13hGetPixel;\r
-  HLine = Mode13hHLine;\r
-  VLine = Mode13hVLine;\r
-  Line = Mode13hLine;\r
-  Circle = Mode13hCircle;\r
-  CircleFill = Mode13hCircleFill;\r
-  Rect = Mode13hRect;\r
-  RectFill = Mode13hRectFill;\r
-  DriverDesc = "320x200 (Mode 13h, linear)";\r
-}\r