home *** CD-ROM | disk | FTP | other *** search
/ The Party 1994: Try This At Home / disk_image.bin / source / less_src / total.txt < prev   
Text File  |  1995-04-18  |  29KB  |  1,445 lines

  1. /* NOTE: THIS IS A COMPILATION OF ALL THE RELATED SOURCE CODE. YOU CAN NOT
  2.    COMPILE THIS! */
  3.  
  4. #include <dos.h>
  5. #include <mem.h>
  6. #include <math.h>
  7. extern void clrscr(void);
  8. void setmode(void)
  9. {
  10.     int i;
  11.     static unsigned int CrtParms[]=
  12.      { 0xd06,0x3e07,0xc009,0xea10,0xac11,0xdf12,0x0014,0xe715,0x616,
  13.          0xe317 };
  14.     _AX=0x13;
  15.     geninterrupt(0x10);//}
  16.     outport(0x3c4,0x604);
  17.     outport(0x3c4,0x100);
  18.     outportb(0x3c2,0xe3/*0xe7*/);
  19.     outport(0x3c4,0x300);
  20.     outportb(0x3d4,0x11);
  21.     outportb(0x3d5,inportb(0x3d5)&0x7f);
  22.     for (i=0;i<10;i++) outport(0x3d4,CrtParms[i]);
  23.     clrscr();
  24. }
  25. #define C_EOB 0
  26. #define C_EOS 0
  27. #define CRUNCH(a,b) \ ((a)*16+(b))
  28.  
  29.  
  30. #define C_LINE(X1,Y1,X2,Y2) \
  31.     CRUNCH(X1,Y1),CRUNCH(((X1)+(X2))/2,((Y1)+(Y2))/2), \
  32.     CRUNCH(((X1)+(X2))/2,((Y1)+(Y2))/2),CRUNCH(X2,Y2)
  33. #define C_BEZIER(X1,Y1,X2,Y2,X3,Y3,X4,Y4) \
  34.     CRUNCH(X1,Y1),CRUNCH(X2,Y2),CRUNCH(X3,Y3),CRUNCH(X4,Y4)
  35.  
  36. // All delays are in frames (1/70s)
  37. char cmdtable[]={
  38.  
  39. //--------- 4 V1.0 ---------
  40.  0x11,0x17,0x17,0x77,        // 4
  41.  0x77,0x77,0x76,0x76,
  42.  0x76,0x16,0x26,0x21,
  43.  0x21,0x21,0x11,0x11,
  44.  0x51,0x51,0x5b,0x5b,
  45.  0x5b,0x5b,0x5b,0x5b,
  46.  0x5b,0x5b,0x6b,0x6b,
  47.  0x6b,0x6b,0x61,0x61,
  48.  0x61,0x61,0x51,0x51,
  49.  0x51,0x51,0x51,0x51,
  50.  
  51.  0x81,0x81,0x8b,0x8b,        // K
  52.  0x8b,0x8b,0x9b,0x9b,
  53.  0x9b,0x9b,0x91,0x91,
  54.  0x91,0x91,0x81,0x81,
  55.  
  56.  0xb1,0x88,0x85,0xbb,
  57.  0xbb,0xbb,0xcb,0xcb,
  58.  0xcb,0x94,0x99,0xc1,
  59.  0xc1,0xc1,0xb1,0xb1,
  60.  
  61. //------------------------
  62.  0x01,0x11,0xb1,0xb6,0xb6,        // O
  63.  0xb6,0xb6,0xa6,0xa6,
  64.  0xa1,0xa2,0xa2,0x12,
  65.  0x12,0x11,0x11,0x12,
  66.  0x26,0x35,0x15,0xb5,
  67.  0xb5,0xb5,0xb5,0xb5,
  68.  0xb5,0xb6,0xb6,0xb6,
  69.  0xb6,0x26,0x12,0x12,
  70.  0x12,0x12,0x22,0x22,
  71.  0x22,0x22,0x22,0x2c,
  72.  
  73.  0x17,0x18,0x18,0xb8,                            // R
  74.  0xb8,0xb9,0xb9,0xb9,
  75.  0xb9,0x19,0x2b,0x2b,
  76.  0x2b,0x2b,0x1b,0x1b,
  77.  
  78.  0x1b,0x86,0x5b,0xbb,
  79.  0xbb,0xbc,0xbc,0xbc,
  80.  0xb8,0x5c,0x8c,0x2c,
  81.  0x2c,0x1c,0x1b,0x10,
  82.  
  83. // ------------------------
  84.  0x01,0x0b,0x0b,0x2b,                     // L
  85.  0x2b,0x2b,0x2a,0x2a,
  86.  0x2a,0x0a,0x1a,0x11,
  87.  0x11,0x11,0x01,0x01,
  88.  
  89.  0x31,0x36,0x3b,0x3b,                       // E
  90.  0x6b,0x6b,0x6a,0x6a,
  91.  0x6a,0x3a,0x36,0x66,
  92.  0x66,0x36,0x32,0x62,
  93.  0x62,0x62,0x61,0x61,
  94.  0x61,0x61,0x31,0x31,
  95.  
  96.  0xa1,0x51,0xba,0x7a,                             // S
  97.  0x7a,0x7a,0x7b,0x7b,
  98.  0x7b,0xcb,0x62,0xa2,
  99.  0xa2,0xa2,0xa1,0xa1,
  100.  
  101.  0xd1,0x81,0xea,0xaa,                             // S
  102.  0xaa,0xaa,0xab,0xab,
  103.  0xab,0xfb,0x92,0xd2,
  104.  0xd2,0xd2,0xd1,0xd1,
  105.  
  106. 0x00
  107.  
  108. };
  109. #define SIZECHANGE -2
  110. #define ENDOFTABLE -1,-1
  111.  
  112. int lengthtable[]={
  113.  60,60,
  114. ENDOFTABLE
  115. };
  116.  
  117. char delaytable[]={
  118.  100,100,1
  119. };
  120.  
  121. #include <dos.h>
  122. #include <mem.h>
  123. #include <stdio.h>
  124. #include <stdlib.h>
  125. #pragma inline
  126. #define PROTECT
  127. #define MATRIXSIZE 20
  128.  
  129. #define I asm
  130. #define XPos 32
  131. #define YPos 34
  132. #define Xsize 128
  133. #define Ysize 64
  134. #define SCALE_FACTOR 16
  135. //2
  136. extern char Liike[];
  137. extern int lasttodraw;
  138. extern int *ScanRight;
  139. extern int *ScanLeft;
  140. extern int *ScanRCount;
  141. extern int *ScanLCount;
  142. extern long *sintaulu;
  143. extern long *costaulu;
  144.  
  145. extern void pixel(int,int,int);
  146. void CalcLandScape(void);
  147. void setmode(void);
  148. void piirralauta(void);
  149. unsigned char *CurPalette;
  150.  
  151. typedef void (*funcptr)(void);
  152.  
  153. extern void ScanConvert(int x,int y,int x1,int y1,int *Scanner);
  154. extern int *ScanRight;
  155. extern int *ScanLeft;
  156. void SetPage(unsigned offs)
  157. {
  158. I mov dx,03d4h
  159. I mov bx,offs
  160. I mov al,0ch
  161. I mov ah,bh
  162. I out dx,ax
  163. I inc al
  164. I mov ah,bl
  165. I out dx,ax
  166. }
  167. volatile unsigned drawoffs=19200;
  168.  
  169. void rotate(int,int,int);
  170. void LaskeSpeeds(void);
  171.  
  172. volatile int XN=0,YN=0;
  173. volatile int KN=0;
  174. volatile int XA,YA,KA;
  175. int volatile TM;
  176. volatile char *LiikePtr=Liike;
  177.  
  178. volatile int P_i=90,P_X=20,P_Y=20;
  179. volatile int P_XCount=0,P_YCount=0,P_icount=0;
  180. void VahennaTime(void)
  181. {
  182.          if (lasttodraw>0) lasttodraw-=8;
  183.          if (TM>0) TM--; else
  184.             {
  185.             if (TM!=-1) {
  186.                 XA=LiikePtr[0];
  187.                 YA=LiikePtr[1];
  188.                 KA=LiikePtr[2];
  189.                 TM=LiikePtr[3];
  190.                 LiikePtr+=4;
  191.             }
  192.                 else {lasttodraw+=16;return;}
  193.             }
  194.  
  195.             P_icount+=(KN+=KA);
  196.         if (P_icount<0) {P_i--;P_icount+=SCALE_FACTOR;} else
  197.         if (P_icount>SCALE_FACTOR) {P_i++;P_icount-=SCALE_FACTOR;}
  198.         if (P_i<0) P_i+=360;
  199.         if (P_i>=360) P_i-=360;
  200.         P_YCount+=(YN+=YA);
  201.         if (P_YCount<0) {P_Y--;P_YCount+=SCALE_FACTOR;} else
  202.         if (P_YCount>SCALE_FACTOR) {P_Y++;P_YCount-=SCALE_FACTOR;}
  203.         P_XCount+=(XN+=XA);
  204.         if (P_XCount<0) {P_X--;P_XCount+=SCALE_FACTOR;} else
  205.                 if (P_XCount>SCALE_FACTOR) {P_X++;P_XCount-=SCALE_FACTOR;}
  206. }
  207.  
  208. void CalcSinTable(void);
  209.  
  210.  
  211.  
  212. extern char *landscape;
  213. extern long *XCoord;
  214. extern long *YCoord;
  215. extern int *XIndex;
  216. extern int *YIndex;
  217. extern int *XIndex1;
  218. extern int *YIndex1;
  219. extern long *matrixZ;
  220. extern void far TimerHandler(void);
  221. void SetIntVec(char,unsigned,unsigned);
  222.  
  223. void clrscr(void)
  224. {
  225.      I push es
  226.     outport(0x3c4,0x0f02);
  227.     _ES=0xa000;
  228.     _EDI=drawoffs;
  229.     _ECX=4800;
  230.     _EAX=0;
  231.     I rep stosd
  232.     I pop es
  233. }
  234. void waitscreen(void);
  235.  
  236. void main_1()
  237. {
  238.     char  l_andscape[22500];
  239.     long AXCoord[MATRIXSIZE*MATRIXSIZE];
  240.     long AYCoord[MATRIXSIZE*MATRIXSIZE];
  241.     int AXIndex[(MATRIXSIZE+1)*(MATRIXSIZE+1)];
  242.     int AYIndex[(MATRIXSIZE+1)*(MATRIXSIZE+1)];
  243.     int AXIndex1[(MATRIXSIZE+1)*(MATRIXSIZE+1)];
  244.     int AYIndex1[(MATRIXSIZE+1)*(MATRIXSIZE+1)];
  245.     long AMatrixZ[MATRIXSIZE*MATRIXSIZE];
  246.     long A_sintaulu[360],A_costaulu[360];
  247.     int End_effect(void);
  248.     int j,item;
  249.     XCoord=AXCoord;
  250.     YCoord=AYCoord;
  251.     XIndex=AXIndex;
  252.     YIndex=AYIndex;
  253.     XIndex1=AXIndex1;
  254.     YIndex1=AYIndex1;
  255.     _DI=(int)(matrixZ=AMatrixZ);
  256.     _ES=_DS;
  257.     _CX=MATRIXSIZE*MATRIXSIZE/4;
  258.     asm rep stosd
  259.     drawoffs=0;
  260.     clrscr();
  261.  
  262.     landscape=l_andscape;
  263.     sintaulu=A_sintaulu;costaulu=A_costaulu;
  264.  
  265.         _AX=0;
  266.         _BX=980;
  267.         _CX=_BX;
  268.         _DI=(int)ScanRight;
  269.         I rep stosw
  270.         _CX=_BX;
  271.         _DI=(int)ScanLeft;
  272.         I rep stosw
  273.         _CX=_BX;
  274.         _DI=(int)ScanRCount;
  275.         I rep stosw
  276.         _CX=_BX;
  277.         _DI=(int)ScanLCount;
  278.         I rep stosw;
  279.      drawoffs=19200;
  280.      clrscr();
  281.      CalcSinTable();
  282.      CalcLandScape();
  283.      XA=LiikePtr[0];
  284.      YA=LiikePtr[1];
  285.      KA=LiikePtr[2];
  286.      TM=LiikePtr[3];
  287.      LiikePtr+=4;
  288.  
  289.     SetIntVec(0x8,FP_OFF(TimerHandler),_CS);
  290.     #ifdef PROTECT
  291.     I mov al,0feh
  292.     I out 021h,al
  293.     #endif
  294.     for (;(TM!=-1 || lasttodraw<MATRIXSIZE*MATRIXSIZE);) {
  295.         rotate(P_i,P_X,P_Y);
  296.  
  297.         piirralauta();
  298.  
  299.         waitscreen();
  300.  
  301.         drawoffs^=19200;
  302.         outport(0x3c4,0x0f02);
  303.  
  304.         I mov ax,0a000h
  305.         I mov es,ax
  306.         I mov di,word ptr drawoffs
  307.         I add di,3300
  308.         I mov cx,4062
  309.         I xor eax,eax
  310.         I rep stosd
  311.     }
  312. }
  313. char Liike[]={
  314.     0  ,0  ,0  ,50,
  315.     0  ,0  ,-3 ,20,
  316.     0  ,0  ,0  ,3 ,
  317.     0  ,0  ,3  ,20,
  318.     0  ,1  ,0  ,20,
  319.     0  ,-1 ,-1 ,20,
  320.     0  ,0  ,0  ,20,
  321.     1 ,1  ,0   ,20,
  322.     -1  ,-1 ,0 ,20,
  323.     1  ,0  ,0  ,20,
  324.     0  ,0  ,1  ,50,
  325.     -1 ,0  ,-1 ,20,
  326.     0  ,0  ,-1 ,30,
  327.     0  ,0  ,1  ,20,
  328.     0  ,-1 ,0  ,25,
  329.     0  ,1  ,1  ,25,
  330.     1  ,0  ,-1 ,30,
  331.     0  ,0  ,0  ,50,
  332.     -1 ,1  ,-1 ,15,
  333.     0  ,0  ,0  ,30,
  334.     -1 ,-1 ,1  ,15,
  335.     0  ,0  ,1  ,5 ,
  336.     0  ,0  ,0  ,50,
  337.     0  ,0  ,0  ,-1
  338.  
  339. };
  340. #include <dos.h>
  341. #pragma asm
  342. #define PROTECT
  343. #define I asm
  344. extern void bezier(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4,int color);
  345. void scanconvert2(int,int,int,int,int);
  346. void SetPage(unsigned);
  347.  
  348. extern unsigned drawoffs;
  349.  
  350. extern char cmdtable[];
  351. extern int lengthtable[];
  352. extern char delaytable[];
  353.  
  354. int *wcmdtable;
  355. int *wcmdtable2;
  356. int *xspeed;
  357. int *yspeed;
  358. int color=60;
  359. int oldframes=0;
  360. int framecount=0;
  361. int * cnvrt(register int *a,register int *b,int frames)
  362. {
  363.     int ispeed;
  364.     if (frames!=oldframes) {framecount=0; oldframes=frames; }
  365.                                                  else framecount++;
  366.     if (frames==1) {
  367.         a[0]=b[0];a[1]=b[1];} else {
  368.     frames--;
  369.     a[0]+=(
  370.                  xspeed[framecount]+=
  371.                         ( ( (((b[0])-(a[0])) /frames)-xspeed[framecount]) )>>2   );
  372.     a[1]+=(yspeed[framecount]+=
  373.         ((((b[1])-(a[1]))/(frames)-yspeed[framecount])) >>2) ;
  374.     }
  375.     return a+2;
  376. }
  377.  
  378. int *cnvrtbezier(int *a,int *b,const int frames,int nro)
  379. {
  380.     int i,*k;
  381.     for (i=0;i<=nro;i+=2)
  382.         k=cnvrt(a+i,b+i,frames);
  383.     return k;
  384. }
  385.  
  386. typedef int * (*CNVRTFUNC)(int *,int *,const int);
  387. int *convert(register int *a,int *b,const int frames)
  388. {
  389.     int nro=6;
  390.     do {
  391.                 register int *p=cnvrtbezier(a,b,frames,nro);
  392.             b+=p-a; a=p;
  393.             nro=2;
  394.      } while (*a);
  395.         return a+1;
  396. }
  397.  
  398. int beziernro=1;
  399. extern int *ScanLeft;
  400. extern int *ScanRight;
  401. char *ScanMark;
  402. void ScanConvert(int,int,int,int,int *);
  403. void Fillpatch(int,int,long);
  404.  
  405. void scanconvert2(int x1,register int y1,int x2,register int y2,int color)
  406. {
  407.     int markcode,i,sx;
  408.     if (y1==y2) return;
  409.     if (y2>=240) y2=239;
  410.     if (y1>=240) y1=239;
  411.     if (y1>y2) {
  412.         I mov ax,y1
  413.         I xchg ax,y2
  414.         I mov y1,ax
  415.         I mov ax,x1
  416.         I xchg ax,x2
  417.         I mov x1,ax
  418.         }
  419.     x1+=32;x2+=32;
  420.     if ((ScanMark[y1+1]==0 && ScanMark[y2-1]==0) || (ScanMark[y1+1]==beziernro || ScanMark[y2-1]==beziernro)) {
  421.         markcode=beziernro;
  422.         ScanConvert(x1,y1,x2,y2,ScanLeft);
  423.     } else
  424.     {
  425.         int A,temp;
  426.         markcode=0;
  427.         ScanConvert(x1,y1,x2 ,y2,ScanRight);
  428.         for (A=y1;A<y2;A++) {
  429.             I movzx eax,word ptr A
  430.             I movzx ebx,word ptr ScanLeft
  431.             I movzx ecx,word ptr ScanRight
  432.             I mov dx,[eax*2+ebx]
  433.             I cmp dx,[eax*2+ecx]
  434.             I jle no_swap
  435.             I xchg dx,[eax*2+ecx]
  436.             I mov [eax*2+ebx],dx
  437. no_swap:
  438.  
  439.         }
  440.         _AL=color;
  441.         _AH=_AL;
  442.         I push ax
  443.         I push ax
  444.         I pop ecx
  445.         Fillpatch(y1,y2,_ECX);
  446.     }
  447.     for (i=y1;i<y2;i++) ScanMark[i]=markcode;
  448. }
  449.  
  450.  
  451. #define SET_RES(a)
  452. #define ENABLE_SET(a)
  453. #define SET_RES1(a)
  454. #define ENABLE_SET1(a)
  455.  
  456.  
  457. int * draw(register const int *p)
  458. {
  459.     beziernro=1;
  460.  _ES=_CS;
  461.  _DI=(int)ScanMark;
  462.  _CX=120;
  463.  _EAX=0;
  464.     I rep stosd
  465.     do {
  466.         bezier(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],color);
  467.         p+=8;
  468.         beziernro++;
  469.     } while (*p);
  470.     return (int *)++p;
  471. }
  472. void waitscreen(void)
  473. {
  474.     while((inportb(0x3da)&8));
  475.     SetPage(drawoffs);
  476.     while(0==(inportb(0x3da)&8));
  477. }
  478. void clrscr(void);
  479.  
  480. void partdo(int frame)
  481. {
  482.     convert(wcmdtable,draw(wcmdtable),frame);
  483.     waitscreen();
  484.     drawoffs^=19200;
  485.     clrscr();
  486. }
  487.  
  488.  
  489. void setmode(void);
  490. extern unsigned char *CurPalette;
  491. extern void DoSetPalette(char *pal);
  492. int main_2(void)
  493. {
  494.  char *p;
  495.  char _ScanMark[482];
  496.  int _wcmdtable[2000];
  497.  int frame,temp,i;
  498.  int _xspeed[2000],_yspeed[2000];
  499.  int lengthindex=0;
  500.  ScanMark=_ScanMark;
  501.  _ES=_DS;
  502.  _SI=(int)cmdtable;
  503.  _DI=(int)_wcmdtable;
  504.  _CX=1000;
  505.  _AH=0;
  506. loopppi:
  507. I lodsb
  508. I mov dl,al
  509. I and ax,0f0h
  510. I shl ax,4
  511. I stosw
  512. I mov al,dl
  513. I and ax,0fh
  514. I shl ax,8
  515. I stosw
  516. I loop loopppi
  517.  xspeed=_xspeed;
  518.  
  519.  
  520.  yspeed=_yspeed;
  521.  _DI=FP_OFF(ScanMark);
  522.  _CX=482;
  523.  asm rep stosb
  524.  
  525.  wcmdtable=_wcmdtable;
  526.  setmode();
  527.  SetPage(19200);
  528.      for (temp=0,i=0;temp<63;temp++,i+=3)
  529.      {
  530.                 CurPalette[i+1]=CurPalette[i]=temp/2;
  531.                 CurPalette[i+2]=temp;
  532.  
  533.      }
  534.  
  535.      I push es
  536.         _ES=_DS;
  537.         _DX=FP_OFF(CurPalette);
  538.         _CX=256;
  539.         _BX=0;
  540.         _AX=0x1012;
  541.         geninterrupt(0x10);
  542.  I pop es
  543.  
  544.  draw(wcmdtable);
  545.  for (frame=0;frame<100;frame++) waitscreen();
  546.  do {
  547.  _ES=_DS;
  548.  _CX=2000;
  549.  _BX=_CX;
  550.  _DI=(int)xspeed;
  551.  _AX=0;
  552. I rep stosw
  553.  _DI=(int)yspeed;
  554.  _CX=_BX;
  555.  _AX=0;
  556. I rep stosw
  557.  
  558.      for (frame=lengthtable[lengthindex];frame>0;frame--) {
  559.         partdo(frame);
  560.         partdo(--frame);
  561.     }
  562.         wcmdtable=draw(wcmdtable);
  563.  
  564.         _CX=(unsigned char)delaytable[lengthindex];
  565. l1:
  566.         I push cx
  567.         waitscreen();
  568.         I pop cx
  569.         I loop l1
  570.  } while (lengthtable[++lengthindex]!=-1);
  571.  return 0;
  572. }
  573.  
  574. extern int *ScanRCount;
  575. extern int *ScanLCount;
  576. extern void main_1(void);
  577.  
  578. typedef void far *HANDLER;
  579. HANDLER  OldKbHandler,OldTimerHandler;
  580.  
  581. void VahennaTime(void);
  582.  
  583. void far TimerHandler(void)
  584. {
  585. I pusha
  586. I push cs
  587. I pop ds
  588. I call near ptr VahennaTime
  589. I mov al,20h
  590. I out 20h,al
  591. I popa
  592. I iret
  593. }
  594.  
  595. void SetIntVec(char nro,int hoff,int hseg)
  596. {
  597.     asm push ds
  598.     _DS=hseg;
  599.     _DX=hoff;
  600.     _AH=0x25;
  601.     _AL=nro;
  602.     geninterrupt(0x21);
  603.     asm pop ds
  604. }
  605.  
  606. void main()
  607. {
  608.     int Iseg,Iofs;
  609.     int  A_ScanRight[980];
  610.     int  A_ScanLeft[980];
  611.     int  A_ScanRCount[980];
  612.     int  A_ScanLCount[980];
  613.     char  c_urpalette[768];
  614.     #ifdef PROTECT
  615.     I mov al,0ffh
  616.     I out 021h,al
  617.     #endif
  618.  
  619.     ScanRight=A_ScanRight;
  620.     ScanLeft=A_ScanLeft;
  621.     ScanRCount=A_ScanRCount;
  622.     ScanLCount=A_ScanLCount;
  623.     CurPalette=c_urpalette;
  624.  
  625.     asm push es
  626.     _AX=0x3508;
  627.     geninterrupt(0x21);
  628.     Iseg=_ES;
  629.     Iofs=_BX;
  630.  
  631.     asm pop es
  632.     main_2();
  633.     main_1();
  634.     I cli
  635.     SetIntVec(0x8,Iofs,Iseg);
  636. #ifdef PROTECT
  637.  
  638.     I mov al,0b0h
  639.     I out 021h,al
  640. #endif
  641.     _AX=3;
  642.     geninterrupt(0x10);
  643. }
  644. #include <dos.h>
  645. #include <stdlib.h>
  646.  
  647. #pragma inline
  648. #define I asm
  649.  
  650. #define MATRIXSIZE 20
  651. #define MATRIXLEN 8
  652. #define MATCONST2 2560
  653. #define COLORDIV 930
  654. int lasttodraw=MATRIXSIZE*MATRIXSIZE - 1;
  655.  
  656. int *ScanRight;
  657. int *ScanLeft;
  658. int *ScanRCount;
  659. int *ScanLCount;
  660. extern unsigned drawoffs;
  661. long *sintaulu;
  662. long *costaulu;
  663.  
  664. #define LANDXSIZE 150
  665. #define LANDYSIZE 150
  666.  
  667. char *landscape;
  668.  
  669.  
  670. void CalcLandScape(void)
  671. {
  672.     register int i,j;
  673.     for (i=0;i<LANDYSIZE;i++)
  674.         for (j=0;j<LANDXSIZE;j++)
  675.         {
  676.             int i2=i-80,j2=j-50;
  677.  
  678.             long korkeus=((sintaulu[(((i2*i2-j2*i2)/(5))%350)+5]+32000L)>>9)+
  679.                                                         ((sintaulu[(((j-20)*30)%350)+5]+33000L)>>9);
  680.             if (korkeus<0) korkeus=0;
  681.             landscape[i*LANDXSIZE+j]=(char)korkeus;
  682.         }
  683. }
  684.  
  685. long *matrixZ;
  686.  
  687.  
  688. void CalcSinTable(void)
  689. {
  690.     long v,x,vc=0,xc=0,AA=193948423;
  691.     register int i;
  692.     x=32768L;v=0;
  693.     for (i=0;i<=360;i++) {
  694.         costaulu[i]=x;
  695.         _EAX=x << 15;
  696.         I cdq
  697.         I shl eax,1
  698.         I rcl edx,1
  699.         I idiv dword ptr AA
  700.  
  701.         I sub vc,edx
  702.         I sbb v,eax
  703.         _EAX=vc;
  704.         _EDX=v;
  705.         I add xc,eax
  706.         I adc x,edx
  707.     }
  708.     for (i=0;i<360;i++) {
  709.         if (i<=90) sintaulu[i]=costaulu[90-i]; else
  710.                              sintaulu[i]=costaulu[360+90-i];
  711.     }
  712. }
  713.  
  714. void ScanConvert(int x1,int y1,int x2,int y2,int *Scanner)
  715. {
  716.     int x,y;
  717.     int k,kj;
  718.     int DxA,Dy;
  719.     int count;
  720.     int Sx;
  721.         Sx=((DxA=x2-x1)<0)?-1:1;
  722.     if ((Dy=y2-y1)<0)
  723.     {
  724.         int temp=x1;x1=x2;x2=temp;
  725.         temp=y1;y1=y2;y2=temp;
  726.         I neg word ptr Dy
  727.         I neg word ptr DxA
  728.         I neg word ptr Sx
  729.     }
  730.         I cmp word ptr Dy,0
  731.         I jnl ei_pienempi
  732.         I neg word ptr Dy
  733. ei_pienempi:
  734.         I jnz ei_nolla
  735.         Scanner[y1]=x1;
  736.         return;
  737. ei_nolla:
  738.     I mov ax,DxA
  739.     I cwd
  740.     I idiv word ptr Dy
  741.     I mov word ptr k,ax
  742.     I mov word ptr kj,dx
  743.     I cmp dx,0
  744.     I jnl ei_pienempi1
  745.     I neg word ptr kj
  746. ei_pienempi1:
  747.     Sx+=k;
  748.     count=0;
  749.     _DI=FP_OFF(Scanner);
  750.     _BX=y1;
  751.     _DX=y2;
  752.     I cmp dx,480
  753.     I jng ei__
  754.     I mov dx,480
  755. ei__:
  756.     I shl bx,1
  757.     I shl dx,1
  758.     I add bx,di
  759.     I add dx,di
  760.     _DI=count;
  761.     _CX=kj;
  762.     _AX=x1;
  763. looppi:
  764.     I mov [bx],ax
  765. ei_first:
  766.     I add di,cx
  767.     I jng ei_toinen1
  768.     I add ax,Sx
  769.     I mov si,Dy
  770.     I sub di,si
  771. ei_toinen:
  772.     I add bx,2
  773.     I cmp bx,dx
  774.     I jle looppi
  775.     I jmp kylla_toinen
  776. ei_toinen1:
  777.     I add ax,k
  778.     I add bx,2
  779.     I cmp bx,dx
  780.     I jle looppi
  781. kylla_toinen:;
  782. }
  783.  
  784. void Fillpatch(int y1,int y2,long color)
  785. {
  786.     int x1,x2,y,Dx,sDx,eDx,i,oy;
  787.     char *p;
  788.     static unsigned char LeftMask[]={0xf,0xe,0xc,0x8};
  789.     static unsigned char RightMask[]={1,3,7,0xf};
  790.     oy=y1;
  791.     while (ScanRight[oy]>=320) ScanRight[oy++]=319;
  792.     oy=y2;
  793.     while (ScanRight[oy]>=320) ScanRight[oy--]=319;
  794.     oy=y1;
  795.     while (ScanLeft[oy]<0) ScanLeft[oy++]=0;
  796.     oy=y2;
  797.     while (ScanLeft[oy]<0) ScanLeft[oy--]=0;
  798.      p=(char *)(y1*80+drawoffs);
  799.     outportb(0x3c4,2);
  800.     _ES=0xa000;
  801.     for (y=y1;y<=y2;y++,p+=80) {
  802.         I .386
  803.         _DI=FP_OFF(ScanLeft);
  804.         I mov bx,word ptr y
  805.         I shl bx,1
  806.         I mov si,[bx+di]
  807.         _DI=FP_OFF(ScanRight);
  808.         I mov cx,[bx+di]
  809.         I cmp si,cx
  810.         I jne ei_pois
  811.         continue;
  812. ei_pois:
  813.         I jbe ei_vaihtoa
  814.         I xchg si,cx
  815.         I mov [bx+di],cx
  816.         _DI=FP_OFF(ScanLeft);
  817.         I mov [bx+di],si
  818. ei_vaihtoa:
  819.         _DI=FP_OFF(p);
  820.  
  821.         I mov dx,si
  822.         I and si,3
  823.         I mov al,[si+offset LeftMask]
  824.         I shr cx,2
  825.         I shr dx,2
  826.         I add di,dx
  827.         I sub cx,dx
  828.         I mov dx,03c5h;
  829.         I jle only_one_byte
  830.         I out dx,al
  831.         I mov eax,color
  832.         I stosb
  833.         I mov al,15
  834.         I sub cx,2
  835.         I jz three_bytes
  836.         I jnl not_only_two_bytes
  837.         I jmp only_one_byte
  838. three_bytes:
  839.         I out dx,al
  840.         I mov eax,color
  841.         I stosb
  842.         I mov al,15
  843.         I       jmp only_one_byte
  844. not_only_two_bytes:
  845.         I out dx,al
  846.             I .386
  847.             I inc cx
  848.             I mov eax,color
  849.             I shr cx,1
  850.             I jnc ei_byte
  851.             I stosb
  852. ei_byte:;
  853.             I shr cx,1
  854.             I jnc ei_word
  855.             I stosw
  856. ei_word:;
  857.             I rep stosd
  858.             I mov al,15
  859.  
  860. only_one_byte:
  861.      I push di
  862.      _DI=FP_OFF(ScanRight);
  863.      I mov bx,[bx+di]
  864.      I pop di
  865.      I and bx,3
  866.      I and al,[bx+offset RightMask]
  867.      I out dx,al
  868.      I mov eax,color
  869.      I stosb
  870.     }
  871. }
  872.  
  873. void patch(int *x,int *y,unsigned long color)
  874. {
  875.     int i,MaxIndex,Temp,AA;
  876.     register int MinIndexR,MinIndexL;
  877.     int MinPointY,MaxPointY,TopIsFlat,LeftEdgeDir;
  878.     int CurIndex,PrevIndex;
  879.     int *ScanK;
  880.  
  881.     MaxPointY=MinPointY=y[MinIndexL=MaxIndex=0];
  882.     for (i=1;i<4;i++) {
  883.         if (y[i]<MinPointY) MinPointY=y[MinIndexL=i]; else
  884.         if (y[i]>MaxPointY) MaxPointY=y[MaxIndex=i];
  885.     }
  886.     if (MinPointY==MaxPointY) return;
  887.     MinIndexR=MinIndexL;
  888.     while (y[MinIndexR]==MinPointY) {MinIndexR++;MinIndexR&=3;}
  889.     MinIndexR--;MinIndexR&=3;
  890.     while (y[MinIndexL]==MinPointY) {MinIndexL--;MinIndexL&=3;}
  891.     MinIndexL++;MinIndexL&=3;
  892.     LeftEdgeDir=-1;
  893.     if (0!=(TopIsFlat=(x[MinIndexL]!=x[MinIndexR]) & 1)) {//?1:0)==1) {
  894.         if (x[MinIndexL]>x[MinIndexR]) {
  895.             LeftEdgeDir=1;
  896.             Temp=MinIndexL;
  897.             MinIndexL=MinIndexR;
  898.             MinIndexR=Temp;
  899.         }
  900.     }
  901.     if (MaxPointY-MinPointY-1+TopIsFlat<=0) return;
  902.     PrevIndex=CurIndex=MinIndexL;
  903.     ScanK=ScanLeft;
  904.     for (AA=0;AA<2;AA++) {
  905.         do {
  906.             CurIndex+=LeftEdgeDir;CurIndex&=3;
  907.             ScanConvert(x[PrevIndex],y[PrevIndex],x[CurIndex],y[CurIndex],ScanK);
  908.             PrevIndex=CurIndex;
  909.         } while (CurIndex!=MaxIndex);
  910.         PrevIndex=CurIndex=MinIndexR;
  911.         I neg word ptr LeftEdgeDir
  912.         ScanK=ScanRight;
  913.     }
  914.  
  915.     if (MaxPointY>=240) MaxPointY=239;
  916.     for (i=MinPointY;i<=MaxPointY;i++)
  917.     {
  918.         if (ScanRight[i]<0) ScanRight[i]=0;
  919.         if (ScanRight[i]>=320) ScanRight[i]=319;
  920.         if (ScanLeft[i]<0) ScanLeft[i]=0;
  921.         if (ScanLeft[i]>=320) ScanLeft[i]=319;
  922.     }
  923.     Fillpatch(MinPointY,MaxPointY,color);
  924. }
  925.  
  926. long *XCoord;
  927. long *YCoord;
  928. int *XIndex;
  929. int *YIndex;
  930. int *XIndex1;
  931. int *YIndex1;
  932.  
  933. void rotate(int kulma,int xp,int yp)
  934. {
  935.     int i,j;
  936.     long sinalfa,cosalfa,Zsinalfa,Zcosalfa,Xcosalfa,Xsinalfa,Dsin,Dcos,DsinTemp,DcosTemp;
  937.     int offs1;
  938.     I movzx ebx,word ptr kulma
  939.     I movzx eax,word ptr sintaulu
  940.     I mov esi,[eax+ebx*4]
  941.     I movzx ecx,word ptr costaulu
  942.     I mov edi,[ebx*4+ecx]
  943.     I imul eax,esi,-MATCONST2
  944.     I mov Zsinalfa,eax
  945.     I mov Xsinalfa,eax
  946.     I mov DsinTemp,eax
  947.     I imul eax,edi,-MATCONST2
  948.     I mov Zcosalfa,eax
  949.     I mov Xcosalfa,eax
  950.     I mov DcosTemp,eax
  951.     I imul eax,esi,MATRIXLEN*2*16
  952.     I mov Dsin,eax
  953.     I imul eax,edi,MATRIXLEN*2*16
  954.     I mov Dcos,eax
  955.  
  956.     for (i=0;i<MATRIXSIZE;i++)
  957.     {
  958.         for (j=0;j<MATRIXSIZE;j++)
  959.         {
  960.  
  961.             int Z;
  962.  
  963.             _AL=(landscape[(i+yp)*LANDXSIZE+j+xp]&255);
  964.             _AH=0;
  965.     I mov ecx,dword ptr Xcosalfa
  966.     I add ecx,dword ptr Zsinalfa
  967.     I push ecx
  968.     I mov ecx,dword ptr Zcosalfa
  969.     I sub ecx,dword ptr Xsinalfa
  970.     I cwde
  971.             I shl eax,17
  972.             I mov esi,eax
  973.             I mov edi,ecx
  974.             I sar ecx,1
  975.             I add esi,ecx
  976.             I neg esi
  977.             I sar eax,1
  978.             I sub edi,eax
  979.             I mov ecx,edi
  980.             I sar edi,12
  981.             matrixZ[offs1=i*MATRIXSIZE+j]=_EDI;
  982.  
  983.             I pop eax
  984.             I sar ecx,1
  985.             I sar esi,1
  986.             I sar eax,1
  987.  
  988.             I add ecx,0x4020000
  989.             I jnl ei_neg
  990.             XCoord[offs1]=-5000;
  991.             YCoord[offs1]=-5000;
  992.             I jmp save_values
  993.  
  994. ei_neg:
  995.             I mov edx,100*2
  996.             I imul edx
  997.             I idiv ecx
  998.             I pop ecx*/
  999.  
  1000.             I push ecx
  1001.             I movzx ebx,word ptr offs1
  1002.             I movzx ecx,word ptr XCoord
  1003.             I mov dword ptr [ecx+ebx*4],eax
  1004.             I pop ecx
  1005.  
  1006.  
  1007.             I mov eax,esi
  1008.             I mov edx,100*2
  1009.             I imul edx
  1010.             I idiv ecx
  1011.  
  1012.             I movzx ecx,word ptr YCoord
  1013.             I mov dword ptr [ecx+ebx*4],eax
  1014.  
  1015. save_values:
  1016.             I mov eax,Dcos
  1017.             I add Xcosalfa,eax
  1018.             I mov eax,Dsin
  1019.             I add Xsinalfa,eax
  1020.         }
  1021.         I mov eax,Dcos
  1022.         I add Zcosalfa,eax
  1023.         I mov eax,Dsin
  1024.         I add Zsinalfa,eax
  1025.  
  1026.         I mov eax,DcosTemp
  1027.         I mov Xcosalfa,eax
  1028.  
  1029.         I mov eax,DsinTemp
  1030.         I mov Xsinalfa,eax
  1031.  
  1032.     }
  1033.  
  1034. }
  1035.  
  1036. void SortIndexes(int mini,int maxi)
  1037. {
  1038.     int k,data1,data2;
  1039.     register int i,j;
  1040.     int d;
  1041.     if (maxi>mini) {
  1042.         d=(mini+maxi)>>1;
  1043.         SortIndexes(mini,d);
  1044.         SortIndexes(d+1,maxi);
  1045.         I mov ax,ds
  1046.         I mov es,ax
  1047.         I movzx eax,word ptr mini
  1048.         I movzx esi,word ptr XIndex
  1049.         I movzx edi,word ptr XIndex1
  1050.         I lea esi,[esi+2*eax]
  1051.         I lea edi,[edi+2*eax]
  1052.         I movzx ecx,word ptr maxi
  1053.         I sub ecx,eax
  1054.         I inc ecx
  1055.         I shr ecx,1
  1056.         I jnc ei_wordi
  1057.         I movsw
  1058. ei_wordi:
  1059.         I rep movsd
  1060.  
  1061.         I movzx esi,word ptr YIndex
  1062.         I movzx edi,word ptr YIndex1
  1063.         I movzx eax,word ptr mini
  1064.      I lea esi,[esi+2*eax]
  1065.      I lea edi,[edi+2*eax]
  1066.         I movzx ecx,word ptr maxi
  1067.         I sub ecx,eax
  1068.         I inc ecx
  1069.         I shr ecx,1
  1070.         I jnc ei_wordi1
  1071.         I movsw
  1072. ei_wordi1:
  1073.         I rep movsd
  1074.  
  1075.  
  1076.      for (i=k=mini,j=d+1;k<=maxi;k++)
  1077.             if (i>d)
  1078.                 {XIndex[k]=XIndex1[j];YIndex[k]=YIndex1[j++];} else
  1079.             if (j>maxi)
  1080.                 {XIndex[k]=XIndex1[i];YIndex[k]=YIndex1[i++];} else
  1081.  
  1082.             if (matrixZ[XIndex1[i]*MATRIXSIZE+YIndex1[i]]<matrixZ[XIndex1[j]*MATRIXSIZE+YIndex1[j]])
  1083.                 {XIndex[k]=XIndex1[i];YIndex[k]=YIndex1[i++];} else
  1084.                 {XIndex[k]=XIndex1[j];YIndex[k]=YIndex1[j++];}
  1085.  
  1086.     }
  1087. }
  1088.  
  1089.  
  1090. void DoSortIndex(void)
  1091. {
  1092.     static int Done=0;
  1093.     register int i,j;
  1094.     if (!Done) { Done=1;
  1095.      I movzx esi,XIndex
  1096.      I movzx edi,YIndex
  1097.      I xor eax,eax
  1098.      I mov dx,MATRIXSIZE-1
  1099. l2:
  1100.      I mov cx,MATRIXSIZE-1
  1101. l1:
  1102.      I mov word ptr [esi+eax*2],dx
  1103.      I mov word ptr [edi+eax*2],cx
  1104.      I inc ax
  1105.      I loop l1
  1106.      I dec dx
  1107.      I jnl l2
  1108.     }
  1109.     SortIndexes(0,MATRIXSIZE*MATRIXSIZE-1);
  1110. }
  1111.  
  1112. void piirralauta(void)
  1113. {
  1114.     int tabX[4],tabY[4];
  1115.     int i,j;
  1116.     int k;
  1117.     int color;
  1118.  
  1119.     DoSortIndex();
  1120.     for (k=MATRIXSIZE*MATRIXSIZE;k>=lasttodraw;k--)
  1121.         {
  1122.             int AA;
  1123.             register long *XAPtr,*YAPtr;
  1124.             i=XIndex[k];
  1125.             j=YIndex[k];
  1126.             AA=i*MATRIXSIZE+j;
  1127.             if ((unsigned)i>=MATRIXSIZE-1 || (unsigned)j>=MATRIXSIZE-1) continue;
  1128.  
  1129.             XAPtr=XCoord+AA;
  1130.             tabX[0]=XAPtr[0]+160;
  1131.             tabX[1]=XAPtr[MATRIXSIZE]+160;
  1132.             tabX[2]=XAPtr[MATRIXSIZE+1]+160;
  1133.             tabX[3]=XAPtr[1]+160;
  1134.  
  1135.             YAPtr=YCoord+AA;
  1136.             tabY[0]=YAPtr[0]+120;
  1137.             tabY[1]=YAPtr[MATRIXSIZE]+120;
  1138.             tabY[2]=YAPtr[MATRIXSIZE+1]+120;
  1139.             tabY[3]=YAPtr[1]+120;
  1140.             color=30-(matrixZ[AA]/COLORDIV);
  1141.  
  1142.             if ((tabX[0] & tabX[1] & tabX[2] & tabX[3])<0) continue;
  1143.             if (tabX[0]>=320 && tabX[1]>=320 && tabX[2]>=320 && tabX[3]>=320) continue;
  1144.             if (tabY[0]>=240 && tabY[1]>=240 && tabY[2]>=240 && tabY[3]>=240) continue;
  1145.             if ((tabY[0]|tabY[1]|tabY[2]|tabY[3])<0) {continue;}
  1146.  
  1147.                 _ECX=color;
  1148.                 _CH=_CL;
  1149.                 I push Cx
  1150.                 I push Cx
  1151.                 I pop eCx
  1152.                 patch((int*)tabX,(int*)tabY,_ECX);
  1153.         }
  1154. }
  1155.  
  1156.  
  1157. .model tiny,Pascal
  1158. .386
  1159. dosseg
  1160. locals
  1161. bezier_only = 1
  1162.  
  1163. screen_seg segment para public use16
  1164. screen_seg ends
  1165.  
  1166. .code
  1167. extrn scanconvert2:proc
  1168.  
  1169. public bezier
  1170.  
  1171. oldsp dw 0
  1172. oldss dw 0
  1173. allocaddr dw 0
  1174. currentx dw 0
  1175. currenty dw 0
  1176. depth dw 0
  1177. bezier_t proc x1:WORD,y1:WORD,x2:WORD,y2:WORD,x3:WORD,y3:WORD,x4:WORD,y4:WORD,color:WORD
  1178.     local r1x:WORD,r1y:WORD,r2x:WORD,r2y:WORD,r3x:WORD,r3y:WORD,q1x:WORD,q1y:WORD,q2x:WORD,q2y:WORD,s1x:WORD,s1y:WORD
  1179.     mov ax,x2
  1180.     mov bx,ax
  1181.     add ax,x1
  1182.     shr ax,1
  1183.     mov r1x,ax
  1184.     mov cx,x3
  1185.     add bx,cx
  1186.     shr bx,1
  1187.     add cx,x4
  1188.     shr cx,1
  1189.     mov r3x,cx
  1190.     add cx,bx
  1191.     add ax,bx
  1192.     shr ax,1
  1193.     shr cx,1
  1194.     mov q1x,ax
  1195.     mov q2x,cx
  1196.     add ax,cx
  1197.     shr ax,1
  1198.     mov s1x,ax
  1199.     mov ax,y2
  1200.     mov bx,ax
  1201.     add ax,y1
  1202.     shr ax,1
  1203.     mov r1y,ax
  1204.     mov cx,y3
  1205.     add bx,cx
  1206.     shr bx,1
  1207.     add cx,y4
  1208.     shr cx,1
  1209.     mov r3y,cx
  1210.     add cx,bx
  1211.     add ax,bx
  1212.     shr ax,1
  1213.     shr cx,1
  1214.     mov q1y,ax
  1215.     mov q2y,cx
  1216.     add ax,cx
  1217.     shr ax,1
  1218.     mov s1y,ax
  1219.     dec depth
  1220.     cmp depth,0
  1221.     jnz ei_lopetus
  1222.     shr s1x,4
  1223.     shr s1y,4
  1224.     call scanconvert2,currentx,currenty,s1x,s1y,color
  1225.     mov ax,s1x
  1226.     mov currentx,ax
  1227.     mov ax,s1y
  1228.     mov currenty,ax
  1229.     inc depth
  1230.     ret
  1231. ei_lopetus:
  1232.     call bezier_t,x1,y1,r1x,r1y,q1x,q1y,s1x,s1y,color
  1233.     call bezier_t,s1x,s1y,q2x,q2y,r3x,r3y,x4,y4,color
  1234.     inc depth
  1235.     ret
  1236. endp
  1237. bezier proc x1:WORD,y1:WORD,x2:WORD,y2:WORD,x3:WORD,y3:WORD,x4:WORD,y4:WORD,color:WORD
  1238.     mov cl,4
  1239.     mov depth,8
  1240.     mov ax,x1
  1241.     mov currentx,ax
  1242.     mov ax,y1
  1243.     mov currenty,ax
  1244.     shr currentx,cl
  1245.     shr currenty,cl
  1246.     call bezier_t,x1,y1,x2,y2,x3,y3,x4,y4,color
  1247.     shr x4,4
  1248.     shr y4,4
  1249.     call scanconvert2,currentx,currenty,x4,y4,color
  1250.     ret
  1251.  
  1252. endp
  1253.  
  1254. do_it:
  1255.  
  1256. endp
  1257.  
  1258. end
  1259.  
  1260.     NAME    c0
  1261.     PAGE    60,132
  1262.     LOCALS
  1263. ;[]------------------------------------------------------------[]
  1264. ;|      C0.ASM -- Start Up Code                                 |
  1265. ;|                                                              |
  1266. ;|      Turbo C++ Run Time Library                              |
  1267. ;|                                                              |
  1268. ;|      Copyright (c) 1987, 1991 by Borland International Inc.  |
  1269. ;|      All Rights Reserved.                                    |
  1270. ;[]------------------------------------------------------------[]
  1271.  
  1272.                                 __C0__ = 1
  1273.                 __TINY__ = 1
  1274. INCLUDE         C:\BORLANDC\LIB\STARTUP\RULES.ASI
  1275. dosseg
  1276. ;       Segment and Group declarations
  1277.  
  1278. _TEXT           SEGMENT BYTE PUBLIC 'CODE'
  1279.         ENDS
  1280. _FARDATA        SEGMENT PARA PUBLIC 'FAR_DATA'
  1281.         ENDS
  1282. _FARBSS         SEGMENT PARA PUBLIC 'FAR_BSS'
  1283.         ENDS
  1284. IFNDEF __TINY__
  1285. _OVERLAY_       SEGMENT PARA PUBLIC 'OVRINFO'
  1286.         ENDS
  1287. _1STUB_         SEGMENT PARA PUBLIC 'STUBSEG'
  1288.         ENDS
  1289. ENDIF
  1290. _DATA           SEGMENT PARA PUBLIC 'DATA'
  1291.         ENDS
  1292. _INIT_          SEGMENT WORD PUBLIC 'INITDATA'
  1293. InitStart       label byte
  1294.         ENDS
  1295. _INITEND_       SEGMENT BYTE PUBLIC 'INITDATA'
  1296. InitEnd         label byte
  1297.         ENDS
  1298. _EXIT_          SEGMENT WORD PUBLIC 'EXITDATA'
  1299. ExitStart       label byte
  1300.         ENDS
  1301. _EXITEND_       SEGMENT BYTE PUBLIC 'EXITDATA'
  1302. ExitEnd         label byte
  1303.         ENDS
  1304. _CVTSEG         SEGMENT WORD PUBLIC 'DATA'
  1305.         ENDS
  1306. _SCNSEG         SEGMENT WORD PUBLIC 'DATA'
  1307.         ENDS
  1308. IFNDEF __HUGE__
  1309.   _BSS          SEGMENT WORD PUBLIC 'BSS'
  1310.         ENDS
  1311.   _BSSEND       SEGMENT BYTE PUBLIC 'BSSEND'
  1312.         ENDS
  1313. ENDIF
  1314. IFNDEF __TINY__
  1315.   _STACK        SEGMENT STACK 'STACK'
  1316.         ENDS
  1317. ENDIF
  1318.  
  1319.     ASSUME  CS:_TEXT, DS:DGROUP
  1320.  
  1321. ;       External References
  1322.  
  1323. extrn           MAIN:DIST;_main:DIST
  1324. extrn           _exit:DIST
  1325. extrn           __exitbuf:DIST
  1326. extrn           __exitfopen:DIST
  1327. extrn           __exitopen:DIST
  1328. extrn           __setupio:near                  ;required!
  1329. extrn           __stklen:word
  1330. IF LDATA EQ false
  1331. extrn           __heaplen:word
  1332. ENDIF
  1333.  
  1334.     SUBTTL  Start Up Code
  1335.     PAGE
  1336. ;/*                                                     */
  1337. ;/*-----------------------------------------------------*/
  1338. ;/*                                                     */
  1339. ;/*     Start Up Code                                   */
  1340. ;/*     -------------                                   */
  1341. ;/*                                                     */
  1342. ;/*-----------------------------------------------------*/
  1343. ;/*                                                     */
  1344. PSPHigh         equ     00002h
  1345. PSPEnv          equ     0002ch
  1346. PSPCmd          equ     00080h
  1347.  
  1348.         public  __AHINCR
  1349. __AHINCR        equ     1000h
  1350.         public  __AHSHIFT
  1351. __AHSHIFT       equ     12
  1352.  
  1353. IFDEF   __NOFLOAT__
  1354. MINSTACK        equ     128     ; minimal stack size in words
  1355. ELSE
  1356. MINSTACK        equ     256     ; minimal stack size in words
  1357. ENDIF
  1358. ;
  1359. ;       At the start, DS and ES both point to the segment prefix.
  1360. ;       SS points to the stack segment except in TINY model where
  1361. ;       SS is equal to CS
  1362. ;
  1363. _TEXT           SEGMENT
  1364.         ORG     100h
  1365. STARTX          PROC    NEAR
  1366.         mov     dx, cs;DGROUP      ; DX = GROUP Segment address
  1367.         mov     ds, dx
  1368. ;;                mov oldss,ss
  1369. ;;                mov oldsp,sp
  1370.         mov bx,0fffeh;;offset DGROUP:stack__end
  1371.         cli                     ; req'd for pre-1983 88/86s
  1372.         ;;mov dx,seg _STACK
  1373.         mov     ss, dx          ; Set the program stack
  1374.         mov     sp, bx;;offset DGROUP:stack__end-2
  1375.         sti
  1376.         call    MAIN;_main
  1377.  
  1378. ;;                mov dx,oldss
  1379. ;;                mov bx,oldsp
  1380. ;;                cli
  1381. ;;                mov ss,dx
  1382. ;;                mov sp,bx
  1383. ;;                sti
  1384. ExitToDOS       label   near
  1385.                                 mov     ax,4C00h
  1386.                                 int     21h                     ; Exit to DOS
  1387. STARTX          ENDP
  1388. ;;oldss dw 0
  1389. ;;oldsp dw 0
  1390.  
  1391.  
  1392.     SUBTTL  Vector save/restore & default Zero divide routines
  1393.     PAGE
  1394.  
  1395.  
  1396.  
  1397. ; The DGROUP@ variable is used to reload DS with DGROUP
  1398.  
  1399. ;PubSym@         DGROUP@, <dw    ?>, __PASCAL__
  1400.  
  1401. ; __MMODEL is used to determine the memory model or the default
  1402. ; pointer types at run time.
  1403.  
  1404. ;                public __MMODEL
  1405. ;__MMODEL        dw      MMODEL
  1406.  
  1407. _TEXT           ENDS
  1408.  
  1409.         SUBTTL  Start Up Data Area
  1410.         PAGE
  1411.  
  1412. _DATA           SEGMENT
  1413.  
  1414. ;       Magic symbol used by the debug info to locate the data segment
  1415.         public DATASEG@
  1416. DATASEG@        label   byte
  1417.  
  1418.  
  1419. _DATA           ENDS
  1420.  
  1421.  
  1422. _CVTSEG         SEGMENT
  1423. PubSym@         _RealCvtVector, <label  word>,  __CDECL__
  1424.         ENDS
  1425.  
  1426. _SCNSEG         SEGMENT
  1427. PubSym@         _ScanTodVector,  <label word>,  __CDECL__
  1428.         ENDS
  1429.  
  1430. _BSS            SEGMENT
  1431. bdata@          label   byte
  1432.         ENDS
  1433.  
  1434. _BSSEND         SEGMENT
  1435. edata@          label   byte
  1436.         ENDS
  1437. ;public stack__end
  1438. ;_STACK          SEGMENT
  1439. ;stack___           db      128 dup(?) ;;49152 dup(?)               ;minimum stack size
  1440. ;stack__end         db ?
  1441. ;                ENDS
  1442.         END     STARTX
  1443.  
  1444. end
  1445.