home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / CONTRSRC.ZIP / SRC / TFLTDV.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-20  |  20.9 KB  |  708 lines

  1. /*      TFL-TDV Wired Party 94 Contribution
  2.  *
  3.  * This demo uses the MIDAS Sound System and the PDFIK data file maker
  4.  * Greetz go to the autors of these kool libs ....
  5.  *
  6.  * Copyright 1994 TFL-TDV Crew
  7.  *
  8.  * nb: TFL means -= The FLamoots =-
  9.  *     TDV means -= The Dark Vision =-
  10.  *
  11.  * call our WHQ: -= Pleasure Access BBS =- +32-2-3461996 SysOp: Green Kawa
  12.  * 
  13.  * contact Type One : llardin@is2.vub.ac.be
  14.  * contact MorFlame : 100346.535@compuserve.com
  15.  *
  16.  * C Main written by Type One :-)
  17. */
  18.  
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <string.h>
  22. #include <conio.h>
  23. #include <process.h>
  24. #include "midas.h"
  25.  
  26. #define false 0
  27. #define true 1
  28. typedef struct {                        /* define type used for buffering */ 
  29.         int base;
  30.         int flag;
  31. } screen;                                
  32.  
  33. screen          page1,page2,page3;                    /* 3 entities */
  34. screen          *StartAdr,*WorkAdr,*NextAdr,*SwapTmp; /* 3 pointers */
  35. int             Triple;                 /* triple buffering flag */
  36.  
  37. int MichFlag ;
  38.  
  39. ushort          scrSync;                /* screen synchronization value */
  40. unsigned char   OldMode;                /* Old GFX Mode */
  41. unsigned char   Panning;                /* Panning value */
  42. unsigned char   RealPan;                /* effective Panning value */
  43. int             RealAdr;                /* effective screen Start adr. */
  44. int             FlipOfs;                /* flipping adr. */
  45. int             ShiftOfs;               /* Scroll offset */
  46. unsigned char   FlipPan;                /* flipping panning */
  47. unsigned char   VBFlag;                 /* Flag */
  48. int             LineCounter = 0;
  49.  
  50. /************ DataBase parameters *************/
  51. long            OfsinDta=0; /*67874; */         /* offset in DataBase (32 bits) */
  52. char            Datafile[]="tfltdv.dat"; /*"tfltdv.exe";*/ /* name of DataBase */
  53.  
  54. char            ModName[]="darkflam.mod";
  55. char            Docu[] =
  56. "Usage:\tCONTRAST\t[options]\n\n"
  57. "Options:\n"
  58. "\t-sx\tForce Sound Device x (1 = GUS, 2 = PAS, 3 = WSS, 4 = SB,\n"
  59. "\t\t5 = No Sound)\n"
  60. "\t-pxxx\tForce I/O port xxx (hex) for Sound Device\n"
  61. "\t-ix\tForce IRQ x for Sound Device\n"
  62. "\t-dx\tForce DMA channel x for Sound Device\n"
  63. "\t-mxxxxx\tSet mixing rate to xxxxx Hz\n"
  64. "\t-e\tDisable EMS usage\n"
  65. "\t-t\tDisable ProTracker BPM tempos\n"
  66. "\t-u\tEnable Surround\n"
  67. "\t-oxxx\tForce output mode (8 = 8-bit, 1 = 16-bit, s = stereo, m = mono\n"
  68. "\t     \t                   h, n, l = high / normal / low quality)\n"
  69. "\t-wx\t7-Mode parameters (0 = No VGA compatible, 1 = VGA compatible)\n"
  70. "\t-gxx\tnumber of the starting part (1-17)\n";
  71.  
  72.  
  73. char            EndText[] =
  74. "You have watched -= CONTRAST =-, our contribution to the WIRED Party 94 \n\n"
  75. "It wouldn't be possible without the work of the following guyz : \n"
  76. "MorFlame, Type One, Bismark, Sam, Fred, Zoltan, Gopi, Green Kawa, Karma \n"
  77. "Special thxx to Youvi for his Robot pic, to Aldo for the OVNI scan :-), \n"
  78. "to NikoPol & NemRod/Channel38 for the 3D objects and for coding ideas !!!!! \n\n"
  79. "If ya want to contact the TFL-TDV crew, just post your mail to : \n"
  80. "llardin@is2.vub.ac.be (Type One) or 100346.535@compuserve.com (MorFlame) \n\n"
  81. "on BBS just try: STARPORT BBS (mail to Type One) \n"
  82. "                              (mail to MorFlame) \n"
  83. "                 GENESIS BBS  (mail to Type One) \n"
  84. "                              (mail to MorFlame) \n"
  85. "                 PA BBS       (mail to Type One) \n"
  86. "                              (mail to MorFlame TDV) \n\n"
  87. "You can reach us via Pleasure Access BBS (our WHQ): +32-2-3461996 \n\n"
  88. "If ya haven't any Net access, just use the Snail Mail : \n"
  89. "Laurent Lardinois (Type One) , 271 ch. de St Job 1180 Bruxelles - Belgium\n";
  90.  
  91. uchar           vol;
  92. char            oldPIC;                 /* save default int Mask */
  93.  
  94. /****************************************************************************\
  95. *
  96. * Some globals and externals demos vars/proc
  97. *
  98. \****************************************************************************/
  99.  
  100. int             SyncFlag;               /* Synchro bit */
  101. int             FrameCounter;           /* screen synchro WORD */
  102. int             ExitDemo;               /* exit demo FLAG */
  103. int             SpaceBar;               /* Space Bar flag */
  104. int             CPUtime;                /* CPU time FLAG */
  105. int             FadeON;                 /* set _TmpPal flag !!! */
  106. int             VGAcompatible;          /* VGA-compatible flag !!! */
  107. unsigned int    NumPart;                /* Num of Part */ 
  108. extern          char TmpPal;            /* tmp-pal */
  109.  
  110. extern ModulePlayer *MP;                /* current modplayer */
  111. mpInformation       ReplayInfo;         /* playing infos */
  112.  
  113.  
  114. /* Prototypes */
  115.  
  116. extern          void DoSinusTbl(void);  /* calculate a sinus table */
  117. extern          void Amorce(void);      /* init random generator */
  118. extern          int  GetRandom(void);   /* randomizer */
  119. extern          void MCH_Detect(void);  /* VGA+386 Detection */
  120. extern          void WaitVBL(void);     /* Wait VR */
  121.  
  122. /************** Zake by Fred ***************/
  123.  
  124. /* Rotative Zoomer - Type One / GFX: Type One */
  125. extern          void StartZoom(int debpos,int debrow,int finpos,int finrow);  
  126.  
  127. /* bitmap Distorter - Type One / GFX: Zoltan */
  128. extern          void StartDistort(int debpos,int debrow,int finpos,int finrow);
  129.  
  130. /* single Plasma - Type One / GFX: Type One */
  131. extern          void StartPlasma(int debpos,int debrow,int finpos,int finrow);
  132.  
  133. /* double Plasma - Type One / GFX: Type One */
  134. extern          void StartDouble(int debpos,int debrow,int finpos,int finrow);
  135.  
  136. /* bitmap Transformation - Type One / GFX: Zoltan */
  137. extern          void StartTransf(int debpos,int debrow,int finpos,int finrow); 
  138.  
  139. /* Multi-fire - Type One */
  140. extern          void StartMulFire(int debpos,int debrow,int finpos,int finrow);
  141.  
  142. /* IceBerg - Waves effect - Type One / GFX: Zoltan */
  143. extern          void StartIce(int debpos,int debrow,int finpos,int finrow);
  144.  
  145. /* Ik heb een OVNI gezien !!! - Type One / Scan: Aldo */
  146. extern          void StartSnul(int debpos,int debrow,int finpos,int finrow); 
  147.  
  148. /* Contrast Title - Type One / GFX: Zoltan & Fred */
  149. extern          void StartTitle(int debpos,int debrow,int finpos,int finrow);
  150.  
  151. /* Elephant - Fred */
  152. extern          void StartEleph(int debpos,int debrow,int finpos,int finrow);
  153.  
  154. /* Snake - Fred */
  155. extern          void StartSnake(int debpos,int debrow,int finpos,int finrow);
  156.  
  157. /* Sam 's Part */
  158. extern          void MyPart (int debpos,int debrow,int finpos,int finrow);
  159.  
  160. /* StarWars scroller - Bismarck */
  161. extern          void StartStar(int debpos,int debrow,int finpos,int finrow);
  162.  
  163.  
  164. /* Shade lines - Bismarck */
  165. extern          void StartShade(int debpos,int debrow,int finpos, int finrow);
  166.    
  167. /* Doom Mapping - Morflame / GFX: Zoltan */
  168. extern          void Morflame1(int debpos,int debrow,int finpos,int finrow);
  169.  
  170. /* eyes effects - Karma */
  171. extern          void KARMA(int debpos,int debrow,int finpos,int finrow); 
  172.  
  173. /* 3D dots objects - morphing - Gopi */
  174. extern          void GOPI(int debpos,int debrow,int finpos,int finrow); 
  175.  
  176. extern          void PutWarning(void);       /* Only-ASM - Type One */
  177. extern          void EndWarning(void);       /* Fade it ... - Type One */
  178. extern          void PutANSI(void);          /* Put ANSI PA BBS - Type One */
  179.  
  180. void preVR(void);
  181. void immVR(void);
  182. void inVR(void);
  183. void brol(void);
  184.  
  185. /****************************************************************************\
  186. *
  187. *  Main Code : just detect the HardWare, set the delays and call the ASM parts
  188. *
  189. \****************************************************************************/
  190.  
  191. int main(int argc, char *argv[])
  192. {
  193.     mpModule    *mod;  /* on y trouve le master volume !!! */
  194.     int         error,i;
  195.     char        *p;
  196.  
  197.     /* argv[0] is the program name , the
  198.        rest are options which MIDAS should handle */
  199.  
  200.     if (!strcmp(argv[1],"/?")) { 
  201.        puts(Docu); 
  202.        exit(EXIT_SUCCESS);
  203.     } 
  204.  
  205.     NumPart = 1;        /* Part 1 by default */
  206.     p = argv[0];
  207.     for(i = 1; (i < argc) && p; i++) {
  208.        for(p = argv[i]; (*p) && (*p != 'g'); p++); /* scan for GOTO parameter */
  209.        if (*p) {
  210.           sscanf((p+1),"%u", &NumPart);
  211.           p = NULL;
  212.        }
  213.     }
  214.     if ( (NumPart >17) || (NumPart == 0) ) {    /* exit if wrong param */
  215.        exit(EXIT_SUCCESS);
  216.     }
  217.  
  218.     VGAcompatible = 0;  /* No VGA-compatible by default */ 
  219.     p = argv[0];
  220.     for(i = 1; (i < argc) && p; i++) {
  221.        for(p = argv[i]; (*p) && (*p != 'w'); p++); /* scan for 7-mode parameters */
  222.        if (*p) {
  223.           if (*(p+1) == '1') VGAcompatible = 1;
  224.           p = NULL;
  225.        }
  226.     }
  227.  
  228.     MCH_Detect();  /* Check if we have the right CPU/GFX else Exit ... */
  229.  
  230.  
  231.     asm {
  232.         mov ah,0fh /* Save the current Video mode */
  233.         int 10h
  234.         mov OldMode,al
  235.         mov ax,13h  /* Set standard mode 13h 320x200x256 chained */ 
  236.         int 10h    
  237.     }    
  238.  
  239.  
  240.  
  241. /*****************************************************************************\
  242. *   Precalculations ......
  243. *
  244. \*****************************************************************************/
  245.  
  246.     PutWarning();     /* put G.Lagaffe on the screen */
  247.     Amorce();         /* Init Random number generator */
  248.     DoSinusTbl();     /* calculate 1024 sinus*256 (WORD) */
  249.  
  250.     Panning = 0;      /* Default */
  251.     ShiftOfs = 0;
  252.     RealPan = 0;
  253.     RealAdr = 0;
  254.     VBFlag = 0;
  255.     FlipOfs = 0;
  256.     FlipPan = 0;
  257.     StartAdr = &page1;
  258.     WorkAdr = &page2;
  259.     NextAdr = &page3;
  260.     StartAdr->flag = false;
  261.     StartAdr->base = 0;
  262.     WorkAdr->flag = false;
  263.     NextAdr->flag = false;  
  264.     Triple = false;
  265.     FadeON = false;
  266.  
  267.     MichFlag = false ;
  268.  
  269. /*****************************************************************************\
  270. *
  271. *   MIDAS settings ....
  272. *
  273. \*****************************************************************************/
  274.  
  275.     /* get Timer screen synchronization value: */
  276.     if ( (error = tmrGetScrSync(&scrSync)) != OK )
  277.         midasError(errorMsg[error]);
  278.  
  279.     midasSetDefaults();                 /* set MIDAS defaults */
  280.     midasParseEnvironment();            /* parse MIDAS environment string */
  281.     midasParseOptions(argc-1, &argv[1]);    /* let MIDAS parse all options */
  282.     midasInit();                        /* initialize MIDAS Sound System */
  283.     mod = midasPlayModule(ModName, 0);  /* load module and start playing */
  284.  
  285.     /* Synchronize Timer to screen. preVR() will be called before
  286.        Vertical Retrace, immVR() just after Vertical Retrace starts and
  287.        inVR() some time later during Vertical Retrace. */
  288.  
  289.     FrameCounter = 0;  /* start counter */
  290.     SyncFlag = 0;
  291.     if ( (error = tmrSyncScr(scrSync, &preVR, &immVR, &inVR)) != OK )
  292.         midasError(errorMsg[error]);
  293.  
  294. /****************************************************************************\
  295. *
  296. * DEMO-Manager : just call the different Pure-ASM parts of the demo !!!!   
  297. *
  298. \****************************************************************************/
  299.  
  300.     asm {
  301.         cli
  302.         in  al,021h /* get int mask */
  303.         mov oldPIC,al
  304.         or  al,02h  /* mask keyboard int **/
  305.         out 021h,al
  306.         sti 
  307.     }
  308.  
  309.     /* Fade Off G.Lagaffe */
  310.     EndWarning();
  311.  
  312.      
  313.     SpaceBar = 0; /* Don't skip the screen by default */
  314.     if (NumPart > 1) SpaceBar = 1; /* skip if we want it !!! */
  315.     
  316.     ExitDemo = 0; /* Don't exit the demo by default !!!! :-) */
  317.     CPUtime = 0;  /* Don't show CPU time by default ... */
  318.  
  319.     /* allocate some mem for player infos (4 voices) */
  320.     ReplayInfo.chans = (mpChanInfo *)malloc(4*sizeof(mpChanInfo));
  321.  
  322.  
  323.     /* Bismarck's SHADELINES */
  324.     if (NumPart == 1) {
  325.        if (SpaceBar) MP->SetPosition(0x00);
  326.        SpaceBar = 0;
  327.        if (!ExitDemo) StartShade(0x00,0x00,0x00,0x02);  
  328.        NumPart++;
  329.     }
  330.  
  331.     /* CONTRAST title */
  332.     if (NumPart == 2) { 
  333.        if (SpaceBar) MP->SetPosition(0x03);
  334.        SpaceBar = 0;
  335.        if (!ExitDemo) StartTitle(0x03,0x03,0x04,0x3c); 
  336.        NumPart++;
  337.     }
  338.  
  339.     /* Do the multi-fire effect */
  340.     if (NumPart == 3) {
  341.        if (SpaceBar) MP->SetPosition(0x05);
  342.        SpaceBar = 0;
  343.        if (!ExitDemo)
  344.        {
  345.           FlipOfs = 80;       /* alternate 80 bytes between each VBL */
  346.           FlipPan = 2;        /* alternate 1 pix between each VBL */
  347.           StartMulFire(0x05,0x1a,0x07,0x2e);  /* Type One's fast+small code */
  348.           FlipPan = 0;
  349.           FlipOfs = 0;         
  350.        }
  351.        NumPart++;
  352.     }
  353.  
  354.     /* Do the rotative Zoom !!!!! */
  355.     if (NumPart == 4) {
  356.        if (SpaceBar) MP->SetPosition(0x09);
  357.        SpaceBar = 0;
  358.        if (!ExitDemo) StartZoom(0x08,0x13,0x11,0x29); /* Type One's fast+small code */
  359.        NumPart++;
  360.     }
  361.  
  362.     /* Do the bitmap Distort !!!! */
  363.     if (NumPart == 5) { 
  364.        if (SpaceBar) MP->SetPosition(0x12);
  365.        SpaceBar = 0;
  366.        if (!ExitDemo) StartDistort(0x12,0x00,0x15,0x30); /* Type One's fast+small code */
  367.        NumPart++;
  368.     }
  369.  
  370.     /* Do the double Plasma !!!! */
  371.     if (NumPart == 6) {
  372.        if (SpaceBar) MP->SetPosition(0x16);
  373.        SpaceBar = 0;
  374.        if (!ExitDemo)
  375.        { 
  376.           FlipOfs=80;                  /* alternate 80 bytes between each VBL */
  377.           StartDouble(0x16,0x00,0x18,0x10); /* Type One's fast+small code */
  378.           FlipOfs=0;
  379.        }
  380.        NumPart++;
  381.     }
  382.  
  383.     /* Sam's Unlimited bobs */
  384.     if (NumPart == 7) {
  385.        if (SpaceBar) MP->SetPosition(0x18);
  386.        SpaceBar = 0;
  387.        if (!ExitDemo) MyPart (0x18,0x3a,0x1e,0x19) ;
  388.        NumPart++;
  389.     }
  390.  
  391.     /* Put the Elephant pic */
  392.     if (NumPart == 8) {
  393.        if (SpaceBar) MP->SetPosition(0x1f);
  394.        SpaceBar = 0;
  395.        if (!ExitDemo) StartEleph(0x1f,0x14,0x20,0x40);
  396.        NumPart++;
  397.     }
  398.  
  399.     /* Gopi's Dots objects */
  400.     if (NumPart == 9) {
  401.        if (SpaceBar) MP->SetPosition(0x21);
  402.        SpaceBar = 0;
  403.        if (!ExitDemo) GOPI(0x20,0x56,0x26,0x00);
  404.        NumPart++;
  405.     }
  406.  
  407.     /* Do the IceBerg (= Waves) effect !!!! */
  408.     if (NumPart == 10) {
  409.        if (SpaceBar) MP->SetPosition(0x28);
  410.        SpaceBar = 0;
  411.        if (!ExitDemo) StartIce(0x28,0x00,0x40,0x30); /* Type One's incredible code */
  412.        NumPart++;
  413.     }
  414.  
  415.     /* Morflame's Doom mapping */
  416.     if (NumPart == 11) {
  417.        if (SpaceBar) MP->SetPosition(0x42);
  418.        SpaceBar = 0;
  419.        if (!ExitDemo) Morflame1(0x42,0x00,0x48,0x18);
  420.        NumPart++;
  421.     }
  422.  
  423.     /* Do the Snul Flash !!!! */
  424.     if (NumPart == 12) {
  425.        if (SpaceBar) MP->SetPosition(0x48);
  426.        SpaceBar = 0;
  427.        if (!ExitDemo) StartSnul(0x48,0x28,0x4a,0x04); /* Type One's ridiculous code */
  428.        NumPart++;
  429.     }
  430.  
  431.     /* Do the single Plasma !!!! */
  432.     if (NumPart == 13) {
  433.        if (SpaceBar) MP->SetPosition(0x4a);
  434.        SpaceBar = 0;
  435.        if (!ExitDemo) StartPlasma(0x4a,0x24,0x4c,0x24); /* Type One's fast+small code */
  436.        NumPart++;
  437.     } 
  438.  
  439.     /* Do the bitmap Transformation !!!! */
  440.     if (NumPart == 14) {
  441.        if (SpaceBar) MP->SetPosition(0x4d);
  442.        SpaceBar = 0;
  443.        if (!ExitDemo) StartTransf(0x4d,0x02,0x4f,0x0c); /* Type One's fast+small code */
  444.        NumPart++;
  445.     }   
  446.  
  447.     /* Karma's eyes effects ... */
  448.     if (NumPart == 15) {
  449.        if (SpaceBar) MP->SetPosition(0x50);
  450.        SpaceBar = 0;
  451.        if (!ExitDemo) KARMA(0x4f,0x30,0x52,0x12); 
  452.        NumPart++;
  453.     } 
  454.  
  455.     /* Put the Snake pic */
  456.     if (NumPart == 16) {
  457.        if (SpaceBar) MP->SetPosition(0x53);
  458.        SpaceBar = 0;
  459.        if (!ExitDemo) StartSnake(0x52,0x36,0x53,0x3f);
  460.        NumPart++;
  461.     }
  462.  
  463.     /* Bismarck's StarWar scroller */
  464.     if (NumPart == 17) {
  465.        if (SpaceBar) MP->SetPosition(0x55);
  466.        SpaceBar = 0;
  467.        if (!ExitDemo) StartStar(0x55,0x00,0xff,0x00); /* Bismarck's StarWar scroller */
  468.        NumPart++;
  469.     }
  470.  
  471.     /* Clear Screen in case of .... */
  472.     asm {
  473.         push es
  474.         push di
  475.         push dx
  476.         push cx
  477.         push ax 
  478.         mov  dx,3c4h
  479.         mov  ax,0f02h
  480.         out  dx,ax
  481.         mov  ax,0a000h
  482.         mov  es,ax
  483.         xor  di,di
  484.         cld
  485.         xor  ax,ax
  486.         mov  cx,32768  /* lame 286 asm :-( */
  487.         rep  stosw
  488.  
  489.         push ds
  490.         pop  es
  491.         xor  ax,ax     /* Black Pal ! */
  492.         mov  di,OFFSET TmpPal
  493.         mov  cx,384
  494.         rep  stosw
  495.  
  496.         push si
  497.         mov  dx,3c8h
  498.         xor  al,al
  499.         out  dx,al
  500.         inc  dl
  501.         mov  si,OFFSET TmpPal
  502.         mov  cx,768
  503.         rep  outsb
  504.         pop  si
  505.  
  506.         pop  ax
  507.         pop  cx
  508.         pop  dx
  509.         pop  di
  510.         pop  es
  511.     }
  512.     
  513.     /* Fade master volume */
  514.     for( vol = (mod->masterVol); vol > 0; vol --) {
  515.          WaitVBL();
  516.          WaitVBL();
  517.          MP->SetMasterVolume(vol);      
  518.     }
  519.     WaitVBL();
  520.     WaitVBL();
  521.     MP->SetMasterVolume(0);
  522.  
  523.  
  524.  
  525. /****************************************************************************\
  526. * END of Da little demo :-)
  527. \****************************************************************************/
  528.  
  529.     /* stop timer screen synchronization: */
  530.     tmrStopScrSync();   
  531.  
  532.     FlipOfs = 0;
  533.     FlipPan = 0;
  534.     Panning = 8;
  535.     WorkAdr->flag = false;
  536.     StartAdr->base = 0;
  537.     preVR();
  538.     immVR();
  539.  
  540.     midasStopModule(mod);               /* stop playing */
  541.     midasClose();                       /* uninitialize MIDAS */
  542.  
  543.     PutANSI();                          /* Put PA BBS Ansi */
  544.  
  545.     asm {                               /* back to TEXT mode ! */
  546.         cli
  547.         mov al,oldPIC /* restore default int Mask */
  548.         out 021h,al
  549.         sti
  550.         xor ah,ah
  551.         mov al,OldMode
  552.         int 10h
  553.     } 
  554.  
  555.     puts(EndText);                      /* Contact us !!! */
  556.  
  557.     return 0;
  558. }
  559.  
  560.  
  561. /****************************************************************************\
  562. *
  563. * Function:     void preVR(void)
  564. *
  565. * Description:  Function that is called before Vertical Retrace. Sets the
  566. *               new screen start address
  567. *
  568. \****************************************************************************/
  569.  
  570. void preVR(void)
  571. {
  572.  
  573. /*  asm {
  574.     push ax
  575.     push dx
  576.     mov  dx,3c8h
  577.     xor  al,al
  578.     out  dx,al
  579.     inc  dl
  580.     mov  al,63
  581.     out  dx,al
  582.     out  dx,al
  583.     out  dx,al
  584.     pop  dx
  585.     pop  ax
  586.    }
  587. */
  588.  
  589.  
  590.   if (!MichFlag) {
  591.  
  592.     if (WorkAdr->flag) {           /* if working buffer completed */
  593.        SwapTmp = StartAdr;         /* swap the screen buffers */
  594.        StartAdr = WorkAdr;         /* show our new frame */
  595.        WorkAdr->flag = false;      /* back to false */
  596.        if (Triple) {               /* swap with 3rd buf if triple-buffering */
  597.           WorkAdr = NextAdr;
  598.           NextAdr = SwapTmp;
  599.           NextAdr->flag = false;
  600.        }
  601.        else WorkAdr = SwapTmp;
  602.        SyncFlag = 1;               /* turn on synchro bit */
  603.     }
  604.  
  605.     RealAdr = StartAdr->base + ShiftOfs;
  606.     if (VBFlag) RealAdr += FlipOfs;/* Calculate effective adr. */
  607.  
  608.     asm {
  609.       mov dx,3D4h
  610.       mov bx,RealAdr
  611.       mov al,0Ch
  612.       mov ah,bh                    /* MSB of screen start adr. */
  613.       out dx,ax
  614.       inc al
  615.       mov ah,bl                    /* LSB of screen start adr. */
  616.       out dx,ax
  617.     } 
  618.  
  619.   }
  620.  
  621.   FrameCounter++;                /* inc the Video synchro counter */
  622. /*
  623.   asm {
  624.     push ax
  625.     push dx
  626.     mov  dx,3c8h
  627.     xor  al,al
  628.     out  dx,al
  629.     inc  dl
  630.     out  dx,al
  631.     out  dx,al
  632.     out  dx,al
  633.     pop  dx
  634.     pop  ax
  635.    }
  636. */
  637.  
  638.  
  639. }
  640.  
  641.  
  642.  
  643. /****************************************************************************\
  644. *
  645. * Function:     void immVR(void)
  646. *
  647. * Description:  Function that is called immediately when Vertical Retrace
  648. *               starts. Sets the new Horizontal Pixel Panning value
  649. *
  650. \****************************************************************************/
  651.  
  652. void immVR(void)
  653. {
  654.  
  655.    RealPan = Panning;                  /* calculate effective panning val. */
  656.    if (VBFlag) RealPan = (RealPan + FlipPan) & 7;
  657.  
  658.    asm {
  659.      mov dx,3C0h
  660.      mov al,33h                        /* New horizontal panning */
  661.      out dx,al
  662.      inc dl
  663.      in  al,dx
  664.      and al,0f8h                       /* 4 bits used */
  665.      or  al,RealPan
  666.      dec dl
  667.      out dx,al
  668.    }
  669.  
  670.    LineCounter = 0;
  671.  
  672. }
  673.  
  674.  
  675.  
  676.  
  677. /****************************************************************************\
  678. *
  679. * Function:     void inVR(void)
  680. *
  681. * Description:  Function that is called some time during Vertical Retrace.
  682. *               Calculates new Horizontal Pixel Panning and screen start
  683. *               address values
  684. *
  685. \****************************************************************************/
  686.  
  687. void inVR(void)
  688. {
  689.  
  690.   VBFlag ^= 1;                          /* XOR 1 */
  691.  
  692.   if(FadeON) {                          /* set new pal ??? */
  693.     asm {
  694.       mov si,OFFSET TmpPal
  695.       mov dx,3c8h
  696.       xor al,al
  697.       out dx,al 
  698.       inc dl
  699.       mov cx,768
  700.       rep outsb
  701.     }
  702.   }
  703.  
  704. }
  705.  
  706.  
  707.