home *** CD-ROM | disk | FTP | other *** search
/ The Party 1994: Try This At Home / disk_image.bin / source / vexsrc / vex.cpp < prev    next >
C/C++ Source or Header  |  1995-03-29  |  17KB  |  701 lines

  1. /*****************************************************************************
  2.                                   ATTENTION!
  3.                            this source is VOTEWARE,
  4.               you may only use it to the conditions listed below:
  5.  
  6.   -You may modify it, or use parts of it in your own source as long as
  7.     this header stays on top of all files containing this source.
  8.   -You must give proper credit to the author, Niklas Beisert / pascal.
  9.   -You may not use it in commercial productions without the written
  10.     permission of the author.
  11.   -AND MOST IMPORTANT: you have to buy an Assembly '94 CD-ROM
  12.     by Sound Solutions (if you don't have it already) and vote for VEX-InTrO
  13.     in the PC-64k-Intro-Compo! (if you have already sent your voting card,
  14.     buy another one and fill it out CORRECTLY!!!)
  15. *****************************************************************************/
  16.  
  17.  
  18.  
  19. // the main program / the scroller with lissajous figures / the "fire"-plasma
  20.  
  21. #include <alloc.h>
  22. #include <stdio.h>
  23. #include <ctype.h>
  24. #include <string.h>
  25. #include <stdlib.h>
  26. #include <dos.h>
  27. #include <conio.h>
  28. #include <io.h>
  29. //#include <fcntl.h>
  30. #include "ovlio.h"
  31. #include "colors2.h"
  32. #include "ints.h"
  33. #include "matrix.h"
  34. #include "vga13x2.h"
  35. #include "polygons.h"
  36. #include "timeruse.h"
  37. #include "keyboard.h"
  38. #include "draw3d.h"
  39. #include "sinplasa.h"
  40.  
  41. #pragma startup tuInstall
  42. #pragma exit tuClose
  43. #pragma startup InstallZeroDivide
  44. #pragma exit DeinstallZeroDivide
  45. #pragma startup InitKey
  46. #pragma exit CloseKey
  47.  
  48.  
  49. extern long* SinTab;
  50.  
  51. #define STEPSIZE 2
  52. #define NUMPOINTS (2048>>STEPSIZE)
  53.  
  54. unsigned scrpage;
  55. long curtime=0;
  56.  
  57. short initscenery(short file);
  58. void closescenery();
  59. void getscenery();
  60. short initpalette(short file);
  61. void setpalette();
  62. void closepalette();
  63. short inittexture(short file);
  64. void closetexture();
  65. short initstars(short file);
  66. void drawstars();
  67. void closestars();
  68.  
  69. //unsigned _stklen=8192;
  70. unsigned _stklen=16000;
  71.  
  72. vector *p3;
  73.  
  74. struct lissapar
  75. {
  76.   long a[3];
  77.   int b[3];
  78.   int c[3];
  79. };
  80. struct lissalist
  81. {
  82.   lissapar l;
  83.   long tv, td;
  84. };
  85. lissalist list[]=
  86.   {{{{dtol(0), dtol(0), dtol(0)}, {0, 0, 0}, {0, 0, 0}}, dtol(2), dtol(5)},
  87.    {{{dtol(1), dtol(1), dtol(0)}, {0, 0, 0}, {512, 0, 0}}, dtol(2), dtol(5)},
  88.    {{{dtol(1), dtol(1), dtol(10)}, {100, 100, 0}, {512, 0, 0}}, dtol(5), dtol(10)},
  89.    {{{dtol(2), dtol(4), dtol(3)}, {123, 320, 12}, {0, 0, 0}}, dtol(5), dtol(5)},
  90.    {{{dtol(7), dtol(7), dtol(8)}, {100, 100, 300}, {512, 0, 0}}, dtol(10), dtol(5)},
  91.    {{{dtol(0), dtol(0), dtol(0)}, {0, 0, 0}, {0, 0, 0}}, dtol(0), dtol(3)},
  92.    {{{dtol(0), dtol(7), dtol(13)}, {2048, -23, -234}, {0, 0, 0}}, dtol(5), dtol(3)},
  93.    {{{dtol(17), dtol(23), dtol(40)}, {123, 234, 56}, {0, 0, 0}}, dtol(7), dtol(3)},
  94.    {{{dtol(29), dtol(21), dtol(50)}, {243, 621, 334}, {0, 0, 0}}, dtol(7), dtol(3)},
  95.    {{{dtol(22), dtol(25), dtol(20)}, {233, 312, 142}, {0, 0, 0}}, dtol(10), dtol(3)},
  96.    {{{dtol(19), dtol(-20), dtol(28)}, {443, 121, 144}, {0, 0, 0}}, dtol(11), dtol(3)},
  97.    {{{dtol(0), dtol(0), dtol(0)}, {0, 0, 0}, {0, 0, 0}}, dtol(0), dtol(0)}};
  98.  
  99. #define NUMLISSA (sizeof list/sizeof(lissalist))
  100.  
  101. void sett0(lissapar& p, long t)
  102. {
  103.   p.c[0]+=IntMul(t, p.b[0]);
  104.   p.c[1]+=IntMul(t, p.b[1]);
  105.   p.c[2]+=IntMul(t, p.b[2]);
  106. }
  107.  
  108. lissapar getmiddle(const lissapar& p1, const lissapar& p2, long t, long T)
  109. {
  110.   lissapar lp=p1;
  111.   long smooth=(SinTab[(IntMulDiv(1024, t, T)-512)&2047]+65536)>>1;
  112.   lp.a[0]+=IntMul(p2.a[0]-p1.a[0], smooth);
  113.   lp.a[1]+=IntMul(p2.a[1]-p1.a[1], smooth);
  114.   lp.a[2]+=IntMul(p2.a[2]-p1.a[2], smooth);
  115.   lp.b[0]+=IntMul(p2.b[0]-p1.b[0], smooth);
  116.   lp.b[1]+=IntMul(p2.b[1]-p1.b[1], smooth);
  117.   lp.b[2]+=IntMul(p2.b[2]-p1.b[2], smooth);
  118.   lp.c[0]+=IntMul(p2.c[0]-p1.c[0], smooth)-IntMul(p2.b[0], IntMul(smooth, T));
  119.   lp.c[1]+=IntMul(p2.c[1]-p1.c[1], smooth)-IntMul(p2.b[1], IntMul(smooth, T));
  120.   lp.c[2]+=IntMul(p2.c[2]-p1.c[2], smooth)-IntMul(p2.b[2], IntMul(smooth, T));
  121.   return lp;
  122. }
  123.  
  124. extern "C" void calclissapoints(vector *, short, long, long, long, long, long, long);
  125.  
  126. void makelissa(const lissapar& p, long t)
  127. {
  128.   long a,b,c,d,e,f;
  129.   a=p.a[0]<<STEPSIZE;
  130.   b=p.a[1]<<STEPSIZE;
  131.   c=p.a[2]<<STEPSIZE;
  132.   d=t*p.b[0]+itol(p.c[0])-1024*p.a[0];
  133.   e=t*p.b[1]+itol(p.c[1])-1024*p.a[1];
  134.   f=t*p.b[2]+itol(p.c[2])-1024*p.a[2];
  135.   calclissapoints(p3, NUMPOINTS, a, b, c, d, e, f);
  136. }
  137.  
  138. void memcpybyte(void *dst, void *src, short n)
  139. {
  140.   asm push ds
  141.   asm cld
  142.   asm mov cx,n
  143.   asm lds si,src
  144.   asm les di,dst
  145.   asm rep movsb
  146.   asm pop ds
  147. }
  148.  
  149. void vgaViewLine(unsigned short l)
  150. {
  151.   outp(0x3d4, 0x0d);
  152.   outp(0x3d5, l);
  153.   outp(0x3d4, 0x0c);
  154.   outp(0x3d5, (l>>8));
  155. }
  156.  
  157. char *text;
  158.  
  159. unsigned short curtextline[20];
  160.  
  161. void getnextline()
  162. {
  163.   short i,j;
  164.   for (i=0; i<20; i++)
  165.     if (!text[i]||text[i]=='\r')
  166.       break;
  167.   memset(curtextline, 0, 40);
  168.   for (j=0; j<i; j++)
  169.     curtextline[j+((20-i)>>1)]=(toupper(*text++)-0x20)<<2;
  170.   if (*text=='\r')
  171.     text++;
  172.   while (*text=='\n')
  173.     text++;
  174. }
  175.  
  176. void plotline(long l)
  177. {
  178.   char *p=(char*)0xA0000000+(l%204)*80;
  179.   outpw(0x3c4, 0x0f02);
  180.   outpw(0x3ce, 0x4105);
  181.   char lineofs=l%20;
  182.   if (!lineofs)
  183.     getnextline();
  184.   for (int i=0; i<20; i++)
  185.     memcpybyte(p+i*4, (char*)0xA000C000+curtextline[i]+lineofs*256, 4);
  186.   memcpybyte(p+16320, p, 80);
  187.   memcpybyte(p+32640, p, 80);
  188.   outpw(0x3ce, 0x4005);
  189. }
  190.  
  191. struct plaspar
  192. {
  193.   long p;
  194.   long ft;
  195.   long f;
  196.   short alpha;
  197.   short omega;
  198. };
  199.  
  200. plaspar par[8]=
  201.   {{dtol(600), dtol(2121.12384), dtol(23.72346), 0, 44},
  202.    {dtol(30), dtol(1032.321234), dtol(7.45923), 512, -24},
  203.    {dtol(100), dtol(923.5741), dtol(66.247345), 1024, 13},
  204.    {dtol(30), dtol(-1014.321234), dtol(23.54023), 52, -43},
  205.    {dtol(123), dtol(-2465.4741), dtol(38.27345), 104, -49},
  206.    {dtol(46), dtol(-1126.321234), dtol(12.92123), 51, 28},
  207.    {dtol(1314), dtol(2217.5741), dtol(42.27445), 124, -40},
  208.    {dtol(70), dtol(-1838.2234), dtol(12.21323485), 1536, 10}};
  209.  
  210.  
  211.  
  212. static void SplitView(unsigned v, unsigned s)
  213. {
  214.   disable();
  215.   outp(0x3d4, 0x0C);
  216.   outp(0x3d5, (((v&~15)*5)>>8));
  217.   outp(0x3d4, 0x0D);
  218.   outp(0x3d5, (v&~15)*5);
  219.   vgaWaitRetrace();
  220.   outp(0x3d4, 0x08);
  221.   outp(0x3d5, inp(0x3d5)&0xE0|(v&15));
  222.  
  223.   outp(0x3d4, 0x18);
  224.   outp(0x3d5, s);
  225.   outp(0x3d4, 0x07);
  226.   outp(0x3d5, inp(0x3d5)&~0x10|((s>>4)&0x10));
  227.   outp(0x3d4, 0x09);
  228.   outp(0x3d5, inp(0x3d5)&~0x40);
  229.   enable();
  230.   tuUpdate();
  231. }
  232.  
  233. #define linebyte(l) ((l)*160)
  234. #define scr(l) MK_FP(0xb800, linebyte(l))
  235.  
  236.  
  237.  
  238. void writestr(char *s)
  239. {
  240.   short a=strlen(s);
  241.   asm mov ah,40h
  242.   asm mov bx,1
  243.   asm mov cx,a
  244.   asm push ds
  245.   asm lds dx,s
  246.   asm int 21h
  247.   asm pop ds
  248. }
  249.  
  250. void main()
  251. {
  252.   writestr("VEX v1.1s. DO NOT SPREAD THIS VERSION!\r\n\r\n\a");
  253.  
  254.   if (coreleft()<450000)
  255.   {
  256.     writestr("you should have at least 512k of free dos-mem to run this intro\r\n");
  257.     writestr("maybe a bit more than that...\r\n");
  258.     return;
  259.   }
  260.  
  261. // load the scenery
  262.   short file=oopen("vexintro.3ds");
  263.   if (file<0)
  264.   {
  265.     writestr("file error\r\n");
  266.     return;
  267.   }
  268.   if (!initscenery(file))
  269.     return;
  270.   if (!inittexture(file))
  271.     return;
  272.   if (!initstars(file))
  273.     return;
  274.   if (!initpalette(file))
  275.     return;
  276.   long endtime;
  277.   oread(file, &endtime, 4);
  278.   oclose(file);
  279.  
  280.   asm mov ah,15
  281.   asm int 0x10
  282.   asm cmp al,3
  283.   asm je modeok
  284.   asm jmp modewrong
  285. modeok:
  286.  
  287.   asm mov ah,2
  288.   asm xor bh,bh
  289.   asm mov dx,0x1900
  290.   asm int 0x10
  291.   memcpy(scr(50), scr(0), linebyte(25));
  292.   SplitView(800, 400);
  293.   memcpy(scr(0), scr(63), linebyte(12));
  294.   memcpy(scr(12), scr(50), linebyte(13));
  295.   int f=oopen("offwego.bin");
  296.   oread(f, scr(25), linebyte(25));
  297.   oclose(f);
  298.   *((char*)scr(25)+1)=0;
  299. #define imaxa 100
  300.   short i;
  301.   for (i=0; i<=imaxa; i++)
  302.     SplitView(208L*i*i/(imaxa*imaxa)+192, 208L*i*i/(imaxa*imaxa)+208);
  303.  
  304. modewrong:
  305.  
  306.   unsigned char (*pals)[256][3]=new unsigned char [3][256][3];
  307.  
  308.   GetColors(pals[0], 0, 256);
  309.   memset(pals[1], 0, 768);
  310.   for (i=0; i<128; i+=4)
  311.   {
  312.     MakeFadeStep(pals[2], pals[0], pals[1], 256, i);
  313.     tuDisable();
  314.     vgaWaitRetrace();
  315.     SetColors(pals[2], 0, 256);
  316.     tuEnable();
  317.     tuUpdate();
  318.   }
  319.  
  320.   asm mov ax,0x13
  321.   asm int 0x10
  322.  
  323. // load the crossfadepic in screen mem
  324.   SetColors(pals[1], 0, 256);
  325.   f=oopen("pdpres.scr");
  326.   oread(f, (char*)0xA0000000, 64000);
  327.   oclose(f);
  328.  
  329.   pals[0][0][0]=pals[0][0][1]=pals[0][0][2]=0x00;
  330.   pals[0][1][0]=pals[0][1][1]=pals[0][1][2]=0x40;
  331.   pals[0][2][0]=pals[0][2][1]=pals[0][2][2]=0x80;
  332.   pals[0][3][0]=pals[0][3][1]=pals[0][3][2]=0xC0;
  333.   memcpy(pals[0][4], pals[0][0], 12);
  334.   memcpy(pals[0][8], pals[0][0], 12);
  335.   memcpy(pals[0][12], pals[0][0], 12);
  336.  
  337. // wait
  338.   tuResetTimer();
  339.   while (tuGetTimer()<dtol(3.8));
  340.  
  341. // fade in
  342.   for (i=0; i<128; i++)
  343.   {
  344.     MakeFadeStep(pals[2], pals[1], pals[0], 256, i);
  345.     tuDisable();
  346.     vgaWaitRetrace();
  347.     tuEnable();
  348.     tuUpdate();
  349.     SetColors(pals[2], 0, 256);
  350.   }
  351.  
  352.   memset(pals[1][0], 0x00, 12);
  353.   memset(pals[1][4], 0x40, 12);
  354.   memset(pals[1][8], 0x80, 12);
  355.   memset(pals[1][12], 0xC0, 12);
  356.  
  357. // wait
  358.   while (tuGetTimer()<dtol(9.7));
  359. // crossfade
  360.   for (i=0; i<128; i++)
  361.   {
  362.     MakeFadeStep(pals[2], pals[0], pals[1], 256, i);
  363.     tuDisable();
  364.     vgaWaitRetrace();
  365.     SetColors(pals[2], 0, 256);
  366.     tuEnable();
  367.     tuUpdate();
  368.   }
  369.  
  370. //wait
  371.   while (tuGetTimer()<dtol(15.5));
  372.  
  373.   vgaWaitRetrace();
  374.   vgaInit();
  375.   memset(pals[0], 255, 768);
  376.   SetColors(pals[2], 0, 256);
  377.   outp(0x3c4, 0xf02);
  378.   memset((char*)0xA0000000, 0, 32768);
  379.   memset((char*)0xA0008000, 0, 32768);
  380.  
  381. // display the scenery
  382.   tuResetTimer();
  383.   scrpage=0;
  384.   short frames=1;
  385.   long lasttime=0;
  386.   while (endtime>curtime)
  387.   {
  388.     curtime=lasttime;
  389. //    curtime+=((70*tuGetTimer()+dtol(0.1))&0xFFFF0000)/70;
  390. //    tuResetTimer();
  391.  
  392. // update the sound buf... (actually there is none in this version ;)
  393.     tuUpdate();
  394.  
  395.     scrpage=(scrpage+1)&3;
  396.  
  397.     vgaFillScreen(scrpage, 0);
  398.  
  399.     drawstars();
  400.     getscenery();
  401.  
  402. // don't update the soundbuf now
  403.     tuDisable();
  404.     vgaViewPage(scrpage);
  405.     vgaWaitRetrace();
  406.     lasttime=tuGetTimer();
  407.     setpalette();
  408. // soundbuf may be updated again
  409.     tuEnable();
  410.     frames++;
  411.   }
  412.  
  413. // free some mem
  414.   closetexture();
  415.   closepalette();
  416.   closescenery();
  417.   closestars();
  418.  
  419.   outpw(0x3c4, 0xf02);
  420.   memset((char*)0xA0000000, 0, 32768);
  421.   vgaViewPage(0);
  422.  
  423.   char *scr=new char[4000];
  424.   char *ps=new char[2048];
  425.   makesintab(ps, 31);
  426.  
  427. // 80*50 graphics
  428.   outp(0x3d4, 9);
  429.   outp(0x3d5, (inp(0x3d5)&0xE0|0x07));
  430.   short c, cb;
  431. // firepalette
  432.   InterpolCols(pals[0], 256, 255, 128, 0, 255, 128, 0);
  433.   InterpolCols(pals[1]+0, 128, 0, 0, 128, 255, 128, 0);
  434.   InterpolCols(pals[1]+128, 128, 255, 128, 0, 255, 255, 0);
  435.  
  436.   tuResetTimer();
  437.   unsigned short page=0;
  438.   curtime=0;
  439.   frames=0;
  440.   while (1)
  441.   {
  442.     page=1-page;
  443.     long p;
  444.     long fx;
  445.     long fy;
  446.     memset(scr, 0, 4000);  // 80*50 = 4000 ;)
  447.     short k;
  448.     for (k=0; k<8; k++)  // 8 operator sine plasma
  449.     {
  450.       short a=par[k].alpha+IntMul(par[k].omega, curtime);
  451.       fx=IntMul(SinTab[(a+512)&2047], par[k].f);
  452.       fy=IntMul(SinTab[a&2047], par[k].f);
  453.       p=par[k].p+IntMul(par[k].ft, curtime)-25*fy-40*fx;
  454.       char *scrp=scr;
  455.       for (i=0; i<50; i++)
  456.       {
  457.         plasmaline(ps, scrp, 80, p, fx);
  458.         p+=fy;
  459.         scrp+=80;
  460.       }
  461.     }
  462.     memcpy((char*)0xA0000000+(page<<14), scr, 4000);
  463.     tuDisable();
  464.     vgaViewPage(page);
  465.     vgaWaitRetrace();
  466.     curtime=tuGetTimer();
  467.     if (frames<=128)
  468.     {
  469.     // fade in
  470.       MakeFadeStep(pals[2], pals[0], pals[1], 256, frames);
  471.       SetColors(pals[2], 0, 256);
  472.       frames++;
  473.     }
  474.     if (curtime>dtol(15))
  475.     {
  476.     // fade out
  477.       if (frames>256)
  478.         break;
  479.       if (frames==129)
  480.         memset(pals[0], 0, 768);
  481.       MakeFadeStep(pals[2], pals[0], pals[1], 256, 256-frames);
  482.       SetColors(pals[2], 0, 256);
  483.       frames++;
  484.     }
  485.     tuEnable();
  486.     tuUpdate();
  487.   }
  488.   tuEnable();
  489.   tuUpdate();
  490.   while (tuGetTimer()<dtol(18));
  491.   delete ps;
  492.   delete scr;
  493.  
  494.   SetColorsBlack();
  495.   outpw(0x3c4, 0xf02);
  496.   memset((char*)0xA0000000, 0, 32768);
  497.   vgaViewPage(0);
  498.  
  499.   outp(0x3d4, 9);
  500.   outp(0x3d5, (inp(0x3d5)&0xE0|0x01));
  501.  
  502.   p3=new vector[NUMPOINTS];
  503.   char *p[2];
  504.   p[0]=new char[NUMPOINTS*3];
  505.   p[1]=new char[NUMPOINTS*3];
  506.   short n[2];
  507.   unsigned short pos[2];
  508.   if (!p3||!p[0]||!p[1])
  509.     return;
  510.  
  511.   unsigned char c2[8][3]={0,0,0,0x70,0x70,0x70,0x9a,0x9a,0x9a,0xc0,0xc0,0xc0,
  512.                           0,0xca,0,0x30,0xc4,0x2c,0x5c,0xc4,0x58,0x84,0xc0,0x84};
  513.  
  514.   char *fnt=new char[20480];
  515.   f=oopen("hooks.fnt");
  516.   oread(f, fnt, 20480);
  517.   oclose(f);
  518.  
  519.   f=oopen("scroll.txt");
  520.   short len=oseek(f, 0, SEEK_END);
  521.   oseek(f, 0, SEEK_SET);
  522.   char *otext=new char[len+1];
  523.   text=otext;
  524.   oread(f, text, len);
  525.   text[len]=0;
  526.   oclose(f);
  527.  
  528.   short j;
  529.   outp(0x3c4, 0x02);
  530.   for (i=0; i<20480; i++)
  531.   {
  532.     outp(0x3c5, (1<<(i&3)));
  533.     *(char*)(0xA000C000+(i>>2))=fnt[i]<<5;
  534.   }
  535.   delete fnt;
  536.  
  537.   memset(pals[0], 0, 768);
  538.  
  539.   for (i=0; i<8; i++)
  540.     for (j=0; j<32; j++)
  541.     {
  542.       if (c2[i][0]+(int)j*4>255)
  543.         pals[1][i*32+j][0]=255;
  544.       else
  545.         pals[1][i*32+j][0]=c2[i][0]+(int)j*4;
  546.       if (c2[i][1]+(int)j*8>255)
  547.         pals[1][i*32+j][1]=255;
  548.       else
  549.         pals[1][i*32+j][1]=c2[i][1]+(int)j*8;
  550.       if (c2[i][2]+(int)j*12>255)
  551.         pals[1][i*32+j][2]=255;
  552.       else
  553.         pals[1][i*32+j][2]=c2[i][2]+(int)j*12;
  554.     }
  555.  
  556.   for (i=0; i<202; i++)
  557.     plotline(i);
  558.   long scrpos=0;
  559.  
  560.   n[0]=n[1]=0;
  561.   page=0;
  562.   tuResetTimer();
  563.   long tm=0;
  564.   int xform=0;
  565.   int curlis=0;
  566.   curtime=0;
  567.   long nexttime=0;
  568.   long lastscroll=0;
  569.   short frmfad=0;
  570.   while (1)
  571.   {
  572.     page=1-page;
  573.     curtime=nexttime;
  574.     tuUpdate();
  575.  
  576.     unsigned short newpos=((scrpos+page*204)%408)*80;
  577.     rdrawpointlst(p[page], n[page], pos[page]);
  578.  
  579.     if ((curtime-lastscroll)>dtol(1/50.0))
  580.     {
  581.       plotline(scrpos+202);
  582.       scrpos++;
  583.       lastscroll=curtime;
  584.     }
  585.  
  586.     curtime-=tm;
  587.  
  588.     lissapar lp;
  589.     if (!xform)
  590.     {
  591.       // do interpolate
  592.       if (list[curlis].tv<=curtime)
  593.       {
  594.         xform=1;
  595.         sett0(list[curlis].l, list[curlis].tv);
  596.         tm+=list[curlis].tv;
  597.         curtime-=list[curlis].tv;
  598.         if ((curlis+1)==NUMLISSA)
  599.           break;
  600.       }
  601.     }
  602.     else
  603.     {
  604.       // do not interpolate
  605.       if (list[curlis].td<=curtime)
  606.       {
  607.         xform=0;
  608.         tm+=list[curlis].td;
  609.         curtime-=list[curlis].td;
  610.         curlis++;
  611.       }
  612.     }
  613.     if (!xform)
  614.       // normal lissajous operation
  615.       lp=list[curlis].l;
  616.     else
  617.       // interpolate between two figures
  618.       lp=getmiddle(list[curlis].l, list[curlis+1].l, curtime, list[curlis].td);
  619.  
  620.     // calc the points
  621.     makelissa(lp, curtime);
  622.     curtime+=tm;
  623.     matrix m,x;
  624.     makematroty(m, IntMul(curtime, 178));
  625.     makematrotz(x, IntMul(curtime, 80));
  626.     matmul(m, x, m);
  627.     makematrotx(x, IntMul(curtime, -50));
  628.     matmul(m, x, m);
  629.     vector xv={0,0,dtol(3)};
  630.     matxlate(m, xv);
  631.     vecxform(p3, p3, m, NUMPOINTS);
  632.  
  633.     pos[page]=newpos;
  634.  
  635.     // project the points
  636.     n[page]=calcpoints3d(p[page], p3, NUMPOINTS, dtol(200), dtol(180), dtol(5), dtol(8));
  637.     outpw(0x3ce, 0x1003);
  638.     // replace the old lissajous points by the new ones
  639.     xchgpointlst(p[page], n[page], pos[page]);
  640.     outpw(0x3ce, 0x0003);
  641.  
  642.     tuDisable();
  643.     vgaViewLine(pos[page]);
  644.     vgaWaitRetrace();
  645.     nexttime=tuGetTimer();
  646.     if (frmfad<=128)
  647.     {
  648.     // fade in
  649.       MakeFadeStep(pals[2], pals[0], pals[1], 256, frmfad);
  650.       SetColors(pals[2], 0, 256);
  651.       frmfad+=2;
  652.     }
  653.  
  654.     tuEnable();
  655.   }
  656.  
  657.   for (i=64; i>=0; i--)
  658.   {
  659.   // fade out
  660.     MakeFadeStep(pals[2], pals[0], pals[1], 256, i*2);
  661.     tuDisable();
  662.     vgaWaitRetrace();
  663.     SetColors(pals[2], 0, 256);
  664.     tuEnable();
  665.     tuUpdate();
  666.   }
  667.  
  668.   vgaClose();
  669.   asm mov ax,3
  670.   asm int 0x10
  671.  
  672.  
  673.   delete pals;
  674.   delete p3;
  675.   delete text;
  676.   delete p[0];
  677.   delete p[1];
  678.  
  679.   memset(scr(25), 0, linebyte(25));
  680.   asm mov ah,2
  681.   asm xor bh,bh
  682.   asm mov dx,0x1900
  683.   asm int 0x10
  684.   SplitView(400, 400);
  685.   f=oopen("vexansi.bin");
  686.   oread(f, scr(50), linebyte(25));
  687.   oclose(f);
  688.   memcpy(scr(0), scr(65), linebyte(10));
  689.   memcpy(scr(10), scr(50), linebyte(15));
  690. #define imaxb 70
  691.   for (i=imaxb; i>=0; i--)
  692.     SplitView(240L*i*i/(imaxb*imaxb)+160, 240L*i*i/(imaxb*imaxb)+240);
  693.   SplitView(800, 400);
  694.   memcpy(scr(0), scr(50), linebyte(25));
  695.   SplitView(0, 400);
  696.   asm mov ah,2
  697.   asm xor bh,bh
  698.   asm mov dx,0x1742
  699.   asm int 0x10
  700. }
  701.