home *** CD-ROM | disk | FTP | other *** search
/ Prima Shareware 3 / DuCom_Prima-Shareware-3_cd1.bin / PROGRAMO / C / ATOLKIT / DEMO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-14  |  22.5 KB  |  828 lines

  1. /***************************************************************************
  2.  
  3.     TITLE:    sptweak.c
  4.  
  5. ****************************************************************************/
  6.  
  7. #include <stdio.h>
  8. #include <malloc.h>
  9. #include <conio.h>
  10.  
  11. #include <dos.h>
  12. #include <fcntl.h>
  13. #include "tweak.h"      /* Fabco's animation kit header declarations */
  14.  
  15.  
  16. /***************************************************************************
  17.  
  18.         VARIOUS DEFINITIONS
  19.  
  20. ****************************************************************************/
  21.  
  22. #pragma pack(1)
  23.  
  24. typedef    unsigned char    uc;
  25. typedef    unsigned int    ui;
  26. typedef    unsigned long    ul;
  27.  
  28. /***************************************************************************
  29.      Mouse stuff
  30. ****************************************************************************/
  31. #define MO_LEFT   1                     /* Mouse left button */
  32. #define MO_RIGHT  2                     /* Mouse right button */
  33.  
  34. typedef struct mcb                      /* Mouse control block structure */
  35. {
  36. int exists,                             /* TRUE if MOUSE exists */
  37.     nbuts,                              /* number of buttons */
  38.     bstat,                              /* button status */
  39.     nclik,                              /* number of clicks */
  40.     col,                                /* position - column */
  41.     row,                                /* position - row */
  42.     hmove,                              /* net horizontal movement */
  43.     vmove;                              /* net vertical movement */
  44.     char *handle;                       /* my own id */
  45. } MOUSE, *MOUSEPTR;
  46.  
  47. /***************************************************************************
  48.         EXTERNAL DECLARATIONS
  49.  ***************************************************************************/
  50.  
  51.  
  52.  
  53. /***************************************************************************
  54.         GLOBAL DATA
  55.  ***************************************************************************/
  56. ui    min_x=0, min_y=0, max_x=319, max_y=199;
  57.  
  58. MOUSEPTR m;                      /* mouse stuff */
  59.  
  60. /***************************************************************************/
  61. void do_background( char huge *buffer_start )
  62. {
  63.     move_backgnd( buffer_start);
  64.  
  65. }
  66.  
  67.  
  68. /* Since there is not enough memory for codeview and the background */
  69. /* at the same time, you can rename this function and disable */
  70. /* the BACKGND define to get a solid color background working */
  71. /* with codeview. This only works with the first method since */
  72. /* the erase has to restore from the background buffer which is */
  73. /* the big memory hog. */
  74.  
  75. void do_background1( void)         /* solid color backgnd */
  76. {
  77.     fill_rectangle(0,0,319,199,14);
  78. }
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87. /****************************************************************************
  88.  
  89.     MAIN( int ARGC, uc *ARGV[] )
  90.     
  91.     Just some kluge code to exercise the assembler rectangle routines.
  92.     
  93.     The Program allocates memory, reads in a background and sprite file,
  94.     and uses a simple for next loop to animate the sprites,
  95.    then it frees up memory, and exits.
  96.  
  97.     One animation method, (not used), redraws the background on every
  98.     frame. Useful in case the background is to be
  99.     scrolled or something.
  100.  
  101.     Then there's the draw/erase cycle.
  102.     This just erases where the sprite has been, 
  103.     and draws the sprite in a new location on the unseen page,
  104.     then switches pages to reveal the new sprite suddenly in place.
  105.     Etc Etc.
  106.  
  107. ****************************************************************************/
  108.  
  109. main( int argc, uc *argv[] ) /* just in case we want to pass in a filename */
  110. {
  111.  
  112. ui         _dos_open();         /* file stuff */
  113. ui         _dos_read();
  114. ui         file_handle;
  115. ui         ammount_read;
  116.  
  117. char huge* backgnd_ptr;         /* storage for the background and sprite */
  118. char huge* sprite_ptr;         /* storage for the starfighter sprite */
  119. char huge* cursor_ptr;         /* storage for cursor */
  120. char huge* temp1_ptr;         /* storage for the save/restore functions */
  121.  
  122. char huge* temp2_ptr;         /* storage for the text sprite */
  123.  
  124. char huge* sound_ptr;       /* storage for the sound file */
  125. char huge* temp_ptr;        /* ptr for the dos read of the sound file */
  126.  
  127. ul            bufflen;             /* long int len of sound buff */
  128. long      *tempLen;             /* remaining length of sound not yet played */
  129. ul            filesize;             /* long int len of file */
  130. ul         i, j;                 /* misc counters */
  131. ui         x1,y1,x2,y2;          /* upper left hand corner of the sprites */
  132. ui         width, height;        /* width and heigth of the sprite. */
  133. ui         c_wid, c_hgh;         /* width and heigth of the cursor. */
  134. ui         prev_row, prev_col;   /* prev coords to erase where we've been */
  135. int        vzoom, hzoom;
  136. int          color;
  137.  
  138.  
  139.  
  140.  
  141.     
  142. set320by200TweakMode();          /* 320x400x256 tweaked mode */
  143.  
  144.  
  145.  
  146. /********************************************************/
  147.     m=(MOUSEPTR)mo_reset();            /* turn on the mouse */
  148.  
  149.  
  150.  
  151.  
  152. #ifndef SCROLL_FROGGY_SCREEN
  153.  
  154.     if ( (backgnd_ptr = (char huge *)halloc(  (65535*4), 1 ))  == NULL )
  155.         {
  156.         set_mode( 3 );
  157.         printf( "\nMemory allocation error for background.\n" );
  158.         exit( 2 );
  159.         }
  160.     
  161.     if ( _dos_open("froggy.twk", O_RDONLY, &file_handle) )
  162.         {
  163.         set_mode( 3 );
  164.         printf("\nUnable to open background. \n" );
  165.         exit( 2 );
  166.          }
  167.     else
  168.         {
  169.         _dos_read( file_handle, backgnd_ptr,     10, &ammount_read); /* throw away the header */
  170.         _dos_read( file_handle, backgnd_ptr,    768, &ammount_read); /* load pallette */
  171.         set_palette(backgnd_ptr);
  172.  
  173.         /* read the background 64k at a whack */
  174.         _dos_read( file_handle, backgnd_ptr, 65535, &ammount_read);
  175.        _dos_read( file_handle, (backgnd_ptr+ 65536),  65535, &ammount_read);
  176.        _dos_read( file_handle, (backgnd_ptr+ 131072), 65535, &ammount_read);
  177.        _dos_read( file_handle, (backgnd_ptr+ 196608), 65535, &ammount_read);
  178.         _dos_close(file_handle);
  179.         }
  180.     for (x1=0,y1=0;    x1<320;    x1+=4 ) 
  181.         {
  182.         scroll_screen( x1,y1, 0,0, 319,199, backgnd_ptr, 640, 64001);
  183.         switch_pages_poll();
  184.         }
  185.     scroll_screen( x1,y1, 0,0, 319,199, backgnd_ptr, 640, 64001);
  186.     switch_pages_poll();
  187.         
  188.     for (x1=320,y1=0;    y1<200;    y1+=1 ) 
  189.         {
  190.         scroll_screen( x1,y1, 0,0, 319,199, backgnd_ptr, 640, 64001);
  191.         switch_pages_poll();
  192.         }
  193.     scroll_screen( x1,y1, 0,0, 319,199, backgnd_ptr, 640, 64001);
  194.     switch_pages_poll();
  195.         
  196.     for (x1=320,y1=200;    x1>4;    x1-=4 ) 
  197.         {
  198.         scroll_screen( x1,y1, 0,0, 319,199, backgnd_ptr, 640, 64001);
  199.         switch_pages_poll();
  200.         scroll_screen( x1,y1, 0,0, 319,199, backgnd_ptr, 640, 64001);
  201.         switch_pages_poll();
  202.         }
  203.     scroll_screen( x1,y1, 0,0, 320,200, backgnd_ptr, 640, 64001);
  204.     switch_pages_poll();
  205.         
  206.     for (x1=0,y1=200;    y1>0;    y1-=1 ) 
  207.         {
  208.         scroll_screen( x1,y1, 0,0, 320,200, backgnd_ptr, 640, 64001);
  209.         switch_pages_poll();
  210.         }
  211.     scroll_screen( x1,y1, 0,0, 320,200, backgnd_ptr, 640, 64001);
  212.     switch_pages_poll();
  213.         
  214.     for (x1=0,y1=0;    x1<320;    x1+=4, y1+=1 ) 
  215.         {
  216.         scroll_screen( x1,y1, 0,0, 320,200, backgnd_ptr, 640, 64001);
  217.         switch_pages_poll();
  218.         scroll_screen( x1,y1, 0,0, 320,200, backgnd_ptr, 640, 64001);
  219.         switch_pages_poll();
  220.         }
  221.     scroll_screen( x1,y1, 0,0, 319,199, backgnd_ptr, 640, 64001);
  222.     switch_pages_poll();
  223.         
  224.     
  225.  
  226.  #ifndef SCROLL_TEXT
  227.     if ( (temp2_ptr = (char huge *)halloc(  (65535), 1 ))  == NULL )
  228.         {
  229.         set_mode( 3 );
  230.         printf( "\nMemory allocation error for text.\n" );
  231.         exit( 2 );
  232.         }
  233.     
  234.     if ( _dos_open("fabco.twk", O_RDONLY, &file_handle) )
  235.         {
  236.         set_mode( 3 );
  237.         printf("\nUnable to open fabco.twk. \n" );
  238.         exit( 2 );
  239.          }
  240.     else
  241.         {
  242.         _dos_read( file_handle, temp2_ptr,     10, &ammount_read); /* throw away the header */
  243.         _dos_read( file_handle, temp2_ptr,    768, &ammount_read); /* load pallette */
  244.  
  245.         /* read the background 64k at a whack */
  246.         _dos_read( file_handle, temp2_ptr, 65535, &ammount_read);
  247.         _dos_close(file_handle);
  248.  
  249.  
  250.        prev_row = 0;
  251.        prev_col = 0;
  252.         for (x1=0,y1=0;    y1<100;    y1+=1 ) 
  253.             {
  254.             scroll_screen( 0,0, 0,0, 320,200, backgnd_ptr, 640, 64001);
  255.             scroll_sprite( x1,y1, 40,0, 180,100, temp2_ptr, 320, 16000);
  256.             switch_pages_poll();
  257.             }
  258.         scroll_screen( 0,0, 0,0, 320,200, backgnd_ptr, 640, 64001);
  259.         scroll_sprite( x1,y1, 40,0, 180,100, temp2_ptr, 320, 16000);
  260.         switch_pages_poll();
  261.         }
  262.  
  263.  
  264.  #endif
  265.         
  266.     hfree(temp2_ptr);                      /* free text buffer */
  267.     hfree(backgnd_ptr);
  268.  
  269.  
  270.         for (i=1; i< 900000; i++)
  271.             ; /* Delay if needed */
  272.  
  273.  
  274.  
  275.     fill_rectangle(0,0,320,200,0);  /* clear screen */
  276.     switch_pages_poll();
  277.     fill_rectangle(0,0,320,200,0);  /* clear screen */
  278.  
  279.  
  280. #endif  /* end of frog screen scroll stuff */
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299. #ifndef DRAW_ERASE_SPRITE
  300.     if ( (backgnd_ptr = (char huge *)halloc(  (65535), 1 ))  == NULL )
  301.         {
  302.         set_mode( 3 );
  303.         printf( "\nMemory allocation error for background.\n" );
  304.         exit( 2 );
  305.         }
  306.     
  307.     if ( _dos_open("bkgnd.twk", O_RDONLY, &file_handle) )
  308.         {
  309.         set_mode( 3 );
  310.         printf("\nUnable to open background. \n" );
  311.         exit( 2 );
  312.          }
  313.     else
  314.         {
  315.         _dos_read( file_handle, backgnd_ptr,     10, &ammount_read); /* throw away the header */
  316.         _dos_read( file_handle, backgnd_ptr,    768, &ammount_read); /* load pallette */
  317.         set_palette(backgnd_ptr);
  318.  
  319.         /* read the background 64k at a whack */
  320.         _dos_read( file_handle, backgnd_ptr, 65535, &ammount_read);
  321.         _dos_close(file_handle);
  322.         }
  323.  
  324.     /* Sprite1 */
  325.     if ( (sprite_ptr = (char huge *)halloc(  65535, 1 ))  == NULL )
  326.         {
  327.         set_mode( 3 );
  328.         printf( "\nMemory allocation error for sprite.\n" );
  329.         exit( 2 );
  330.         }
  331.  
  332.     /* Cursor */
  333.     if ( (cursor_ptr = (char huge *)halloc(  1024, 1 ))  == NULL )
  334.         {
  335.         set_mode( 3 );
  336.         printf( "\nMemory allocation error for cursor.\n" );
  337.         exit( 2 );
  338.         }
  339.     
  340.     if ( _dos_open("sp.twk", O_RDONLY, &file_handle) )
  341.         {
  342.         set_mode( 3 );
  343.         printf("\nUnable to open sprite. \n" );
  344.         exit( 2 );
  345.          }
  346.     else
  347.         {
  348.         _dos_read( file_handle, sprite_ptr,     10, &ammount_read);    /* header */
  349.         width  = (int) *(sprite_ptr + 4);
  350.         height = (int) *(sprite_ptr + 6);
  351.         
  352.         _dos_read( file_handle, sprite_ptr,    768, &ammount_read);
  353.         _dos_read( file_handle, sprite_ptr,  65535, &ammount_read);
  354.         _dos_close(file_handle);
  355.         }
  356.  
  357.     if ( _dos_open("cursor.twk", O_RDONLY, &file_handle) )
  358.         {
  359.         set_mode( 3 );
  360.         printf("\nUnable to open cursor. \n" );
  361.         exit( 2 );
  362.          }
  363.     else
  364.         {
  365.         _dos_read( file_handle, cursor_ptr,     10, &ammount_read);    /* header */
  366.         c_wid  = (int) *(cursor_ptr + 4);
  367.         c_hgh  = (int) *(cursor_ptr + 6);
  368.         
  369.         _dos_read( file_handle, cursor_ptr,    768, &ammount_read);
  370.         _dos_read( file_handle, cursor_ptr,   1024, &ammount_read);
  371.         _dos_close(file_handle);
  372.         }
  373.  
  374.     if ( (temp2_ptr = (char huge *)halloc(  (65535), 1 ))  == NULL )
  375.         {
  376.         set_mode( 3 );
  377.         printf( "\nMemory allocation error for text.\n" );
  378.         exit( 2 );
  379.         }
  380.     
  381.     if ( _dos_open("fabco.twk", O_RDONLY, &file_handle) )
  382.         {
  383.         set_mode( 3 );
  384.         printf("\nUnable to open fabco.twk. \n" );
  385.         exit( 2 );
  386.          }
  387.     else
  388.         {
  389.         _dos_read( file_handle, temp2_ptr,     10, &ammount_read); /* throw away the header */
  390.         _dos_read( file_handle, temp2_ptr,    768, &ammount_read); /* load pallette */
  391.  
  392.         /* read the background 64k at a whack */
  393.         _dos_read( file_handle, temp2_ptr, 65535, &ammount_read);
  394.         _dos_close(file_handle);
  395.         }
  396.  
  397.  
  398. /* load the sound file */
  399.     filesize = (65535*3);
  400.     if ( (sound_ptr = (char huge *)halloc(  filesize, 1 ))  == NULL )
  401.         {
  402.         set_mode( 3 );
  403.         printf( "\nMemory allocation error for sound.\n" );
  404.         exit( 2 );
  405.         }
  406.     
  407.     if ( _dos_open("zz_top.spl", O_RDONLY, &file_handle) )
  408.         {
  409.         set_mode( 3 );
  410.         printf("\nUnable to open sound file. \n" );
  411.         exit( 2 );
  412.          }
  413.     else
  414.         {
  415.         /* throw away the header */
  416.         _dos_read( file_handle,  sound_ptr, 26, &ammount_read);
  417.         
  418.         /* read the rest of the sound file 64k at a whack */
  419.         temp_ptr=sound_ptr;
  420.         bufflen=0;
  421.         while (bufflen < (filesize-27) )
  422.             {
  423.             _dos_read( file_handle, temp_ptr, 65535, &ammount_read);
  424.              temp_ptr+=65535;
  425.              bufflen+=ammount_read;
  426.             }
  427.  
  428.         _dos_close(file_handle);
  429.         }
  430.     
  431.  
  432.  
  433.     do_background(backgnd_ptr);        /* background on page1 */
  434.     switch_pages_poll();
  435.     do_background(backgnd_ptr);        /* background on page2 */
  436.  
  437.    init_speaker_port();
  438.     IRQ0_install();                     /* initialize sound interrupt */
  439.  
  440.     /* sound plays in background on return */
  441.     tempLen = play_sound_IRQ0(sound_ptr, bufflen, 77);    
  442.  
  443.     prev_row = 0;
  444.     prev_col = 0;
  445.     for (x1=250,y1=150;    y1>10;    x1-=1,y1-=1) /* next sprite */
  446.         {
  447.         erase_sprite( prev_col, prev_row, width, height, backgnd_ptr );
  448.         draw_sprite( x1,y1, width, height, sprite_ptr);
  449.         switch_pages_poll();
  450.         erase_sprite( prev_col, prev_row, width, height, backgnd_ptr );
  451.         draw_sprite( x1,y1, width, height, sprite_ptr);
  452.         switch_pages_poll();
  453.        prev_row = y1;
  454.        prev_col = x1;
  455.         }
  456.  
  457.  
  458.  #ifndef SCROLL_WINDOW
  459.     color = 3;
  460.     for (x1=29,y1=29;      x1<=150;    x1+=1)  /* window boarder on page 1 */
  461.          write_pixel_twk(x1, y1, color);
  462.     for (x1=29,y1=130;     x1<=150;    x1+=1) 
  463.          write_pixel_twk(x1, y1, color);
  464.     for (x1=150,y1=29;     y1<=130;    y1+=1) 
  465.          write_pixel_twk(x1, y1, color);
  466.     for (x1=29,y1=29;      y1<=130;    y1+=1) 
  467.          write_pixel_twk(x1, y1, color);
  468.     
  469.     switch_pages_poll();
  470.  
  471.     for (x1=29,y1=29;      x1<=150;    x1+=1)  /* window boarder on page 2 */
  472.          write_pixel_twk(x1, y1, color);
  473.     for (x1=29,y1=130;     x1<=150;    x1+=1) 
  474.          write_pixel_twk(x1, y1, color);
  475.     for (x1=150,y1=29;     y1<=130;    y1+=1) 
  476.          write_pixel_twk(x1, y1, color);
  477.     for (x1=29,y1=29;      y1<=130;    y1+=1) 
  478.          write_pixel_twk(x1, y1, color);
  479.  
  480.  
  481.     for (x1=200;    x1>10;    x1-=1) /* next sprite */
  482.         {
  483.         scroll_window( x1,90, 30,30, 120,100, backgnd_ptr);
  484.         switch_pages_poll();
  485.   #ifdef DELAY
  486.         for (i=1; i< 9000; i++)
  487.             ; /* Delay if needed */
  488.   #endif
  489.         }
  490.     scroll_window( x1,90, 30,30, 120,100, backgnd_ptr);
  491.     switch_pages_poll();
  492.  
  493. do_background(backgnd_ptr);        /* background on page1 */
  494. switch_pages_poll();
  495. do_background(backgnd_ptr);        /* background on page2 */
  496. switch_pages_poll();
  497.  
  498.  #endif
  499.  
  500.  #ifdef SCROLL_ZOOM_WINDOW
  501. scroll_zoom_window( 200,90, 30,30, 120,100, backgnd_ptr, 1,1);
  502. switch_pages_poll();
  503.         getchar();
  504. scroll_zoom_window( 200,90, 30,30, 120,100, backgnd_ptr, 1,2);
  505. switch_pages_poll();
  506.         getchar();
  507. scroll_zoom_window( 200,90, 30,30, 120,100, backgnd_ptr, 2,1);
  508. switch_pages_poll();
  509.         getchar();
  510. scroll_zoom_window( 200,90, 30,30, 120,100, backgnd_ptr, 2,2);
  511. switch_pages_poll();
  512.         getchar();
  513. scroll_zoom_window( 200,90, 30,30, 120,100, backgnd_ptr, 4,4);
  514. switch_pages_poll();
  515.  #endif
  516.  
  517.  #ifdef FATBIT_OUT
  518. fatbit_out( 200,90, 30,30, 120,100, backgnd_ptr, 1,1);
  519. switch_pages_poll();
  520.         getchar();
  521. fatbit_out( 200,90, 30,30, 120,100, backgnd_ptr, 2,2);
  522. switch_pages_poll();
  523.         getchar();
  524. fatbit_out( 200,90, 30,30, 120,100, backgnd_ptr, 3,3);
  525. switch_pages_poll();
  526.         getchar();
  527. fatbit_out( 200,90, 30,30, 120,100, backgnd_ptr, 4,4);
  528. switch_pages_poll();
  529.         getchar();
  530. fatbit_out( 200,90, 30,30, 120,100, backgnd_ptr, 5,5);
  531. switch_pages_poll();
  532.  #endif
  533.  
  534.  #ifndef FADE_ZOOM_OUT
  535. scroll_zoom_window( 200,90, 30,30, 96,100, backgnd_ptr, 1,1);
  536. switch_pages_poll();
  537.         for (i=1; i< 45000; i++)    ;
  538. scroll_zoom_window( 215,95, 30,30, 96,100, backgnd_ptr, 2,2);
  539. switch_pages_poll();
  540.         for (i=1; i< 45000; i++)    ;
  541. scroll_zoom_window( 225,100, 30,30, 96,100, backgnd_ptr, 3,3);
  542. switch_pages_poll();
  543.         for (i=1; i< 45000; i++)    ;
  544. scroll_zoom_window( 230,102, 30,30, 96,100, backgnd_ptr, 4,4);
  545. switch_pages_poll();
  546.         for (i=1; i< 45000; i++)    ;
  547. scroll_zoom_window( 235,104, 30,30, 96,100, backgnd_ptr, 6,6);
  548. switch_pages_poll();
  549.         for (i=1; i< 45000; i++)    ;
  550. scroll_zoom_window( 235,106, 30,30, 96,100, backgnd_ptr, 8,8);
  551. switch_pages_poll();
  552.         for (i=1; i< 45000; i++)    ;
  553. scroll_zoom_window( 235,108, 30,30, 96,100, backgnd_ptr, 12,12);
  554. switch_pages_poll();
  555.         for (i=1; i< 45000; i++)    ;
  556. scroll_zoom_window( 235,110, 30,30, 96,100, backgnd_ptr, 24,24);
  557. switch_pages_poll();
  558.         for (i=1; i< 100000; i++)    ;
  559. do_background(backgnd_ptr);        /* background on page2 */
  560. switch_pages_poll();
  561. do_background(backgnd_ptr);        /* background on page2 */
  562. switch_pages_poll();
  563.  #endif
  564.  
  565.  
  566.  
  567.  
  568.  #ifdef SCROLL_ZOOM_WINDOW
  569.     for (x1=220,y1=100, vzoom=1, hzoom=1;    x1>10;    x1-=1,y1+=0 ) /* next sprite */
  570.         {
  571.         if (x1 == 210)
  572.             hzoom = vzoom = 2;
  573.         if (x1 == 60)
  574.             hzoom = vzoom = 3;
  575.         if (x1 == 50)
  576.             hzoom = vzoom = 4;
  577.         scroll_zoom_window( x1,y1, 30,30, 96,96, backgnd_ptr, vzoom, hzoom);
  578.         scroll_zoom_window( x1,0, 200,40, 96,96, backgnd_ptr, vzoom, hzoom);
  579.         switch_pages_poll();
  580.         }
  581.     scroll_zoom_window( x1,y1, 30,30, 96,96, backgnd_ptr, vzoom, hzoom);
  582.     scroll_zoom_window( x1,0, 200,40, 96,96, backgnd_ptr, vzoom, hzoom);
  583.     switch_pages_poll();
  584. do_background(backgnd_ptr);        /* background on page2 */
  585. switch_pages_poll();
  586. do_background(backgnd_ptr);        /* background on page2 */
  587. switch_pages_poll();
  588.  
  589.  #endif
  590.  
  591.     
  592.     
  593.     
  594.  #ifndef MOUSE
  595.  
  596.    prev_row = 0;
  597.    prev_col = 0;
  598.     for (x1=100,y1=10;    x1<200;    x1+=1 ) 
  599.         {
  600.         scroll_screen( 80,150, 80,150, 140,50, backgnd_ptr, 320, 16000);
  601.         scroll_sprite( x1,y1,  80,150, 140,50, temp2_ptr,   320, 16000);
  602.         switch_pages_poll();
  603.         }
  604.     scroll_screen( 80,150, 80,150, 140,50, backgnd_ptr, 320, 16000);
  605.     scroll_sprite( x1,y1,  80,150, 140,50, temp2_ptr,   320, 16000);
  606.     switch_pages_poll();
  607.     scroll_screen( 80,150, 80,150, 140,50, backgnd_ptr, 320, 16000);
  608.     scroll_sprite( x1,y1,  80,150, 140,50, temp2_ptr,   320, 16000);
  609.     
  610.     mo_pos(m);
  611.     prev_col = m->col/2;        /* convert 640w mouse to 320w screen */
  612.     prev_row = m->row;
  613.        
  614.     while(1)
  615.        {
  616.         mo_pos(m);
  617.         if (m->bstat==MO_LEFT)
  618.           {
  619.   #ifdef HOT_SPOT
  620.           /* determine the hot area where the mouse button was pressed */
  621.           /* and restrict the mouse to this area */
  622.           if (m->col/2 > 50 && m->col/2 < 100 && m->row > 50 && m->row < 100 )
  623.                   {
  624.                   mo_clim(m, m->col, m->col );
  625.                    mo_rlim(m, m->row-20, m->row+20);
  626.               }
  627.   #endif
  628.  
  629.           erase_sprite( prev_col, prev_row, width, height, backgnd_ptr );
  630.           draw_sprite ( m->col/2, m->row, width, height, sprite_ptr);
  631.           draw_sprite( m->col/2, m->row, c_wid, c_hgh, cursor_ptr );
  632.           switch_pages_poll();
  633.     
  634.             erase_sprite( prev_col, prev_row, width, height, backgnd_ptr );
  635.           draw_sprite ( m->col/2, m->row, width, height, sprite_ptr);
  636.           draw_sprite( m->col/2, m->row, c_wid, c_hgh, cursor_ptr );
  637.           switch_pages_poll();
  638.           
  639.             prev_col = m->col/2;        /* convert 640w mouse to 320w screen */
  640.           prev_row = m->row;
  641.  
  642.           }
  643.        else if (m->bstat==MO_RIGHT)
  644.           {
  645.           break;
  646.           }
  647.        else if (m->bstat==3)
  648.           {
  649.           /* release the mouse from restricted movement */
  650.           mo_clim(m, 0, 639);
  651.           mo_rlim(m, 0, 199);
  652.           }
  653.        }
  654.  #endif
  655.  
  656.  #ifdef PAUSE
  657.     /* screen save/restore buffer */
  658.     if ( (temp1_ptr = (char huge *)halloc(  65535, 1 ))  == NULL )
  659.         {
  660.         set_mode( 3 );
  661.         printf( "\nMemory allocation error for get/put.\n" );
  662.         exit( 2 );
  663.         }
  664.     get_rectangle( 100, 100, 40, 40, temp1_ptr );
  665.     fill_rectangle( 100, 100, 40, 40, 14 );
  666.    switch_pages_poll();
  667.         getchar();
  668.     put_rectangle( 100, 100, 40, 40, temp1_ptr );
  669.    switch_pages_poll();
  670.         getchar();
  671.     put_rectangle( 100, 100, 40, 40, temp1_ptr );
  672.    switch_pages_poll();
  673.         getchar();
  674.  #endif
  675.  
  676.  
  677.     hfree(sound_ptr);                     /* free up memory and exit. */
  678.     hfree(temp2_ptr);
  679.     hfree(cursor_ptr);
  680.     hfree(sprite_ptr);                  /* free up memory and exit. */
  681.     hfree(backgnd_ptr);
  682.  
  683.     IRQ0_remove();         
  684.     restore_ports();                      /* cleanup after sound interrupt */
  685.  
  686.     fill_rectangle(0,0,320,200,0);  /* clear screen */
  687.     switch_pages_poll();
  688.     fill_rectangle(0,0,320,200,0);  /* clear screen */
  689.  
  690.  
  691. #endif        /* end of starwars stuff */
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703. #ifdef BITBLT
  704.     for (y1=0; y1<15; y1+=5)
  705.         {
  706.         for (x1=0; x1<310; x1+=1)
  707.             {
  708.             fill_rectangle ( x1, y1, width, height, x1);
  709.             switch_pages_poll();
  710.  #ifdef DELAY
  711.         for (i=1; i< 3000; i++)
  712.             ; /* Delay if needed */
  713.  #endif
  714.             fill_rectangle ( x1, y1, width, height, x1);
  715.             switch_pages_poll();
  716.  #ifdef DELAY
  717.         for (i=1; i< 3000; i++)
  718.             ; /* Delay if needed */
  719.  #endif
  720.             }
  721.         }
  722. #endif
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. #ifndef POOH
  731.  
  732.     if ( (backgnd_ptr = (char huge *)halloc(  (65535), 1 ))  == NULL )
  733.         {
  734.         set_mode( 3 );
  735.         printf( "\nMemory allocation error for background.\n" );
  736.         exit( 2 );
  737.         }
  738.     
  739.     if ( _dos_open("poohbk.twk", O_RDONLY, &file_handle) )
  740.         {
  741.         set_mode( 3 );
  742.         printf("\nUnable to open background. \n" );
  743.         exit( 2 );
  744.          }
  745.     else
  746.         {
  747.         _dos_read( file_handle, backgnd_ptr,     10, &ammount_read); /* throw away the header */
  748.         _dos_read( file_handle, backgnd_ptr,    768, &ammount_read); /* load pallette */
  749.         set_palette(backgnd_ptr);
  750.  
  751.         /* read the background 64k at a whack */
  752.         _dos_read( file_handle, backgnd_ptr, 65535, &ammount_read);
  753.         _dos_close(file_handle);
  754.         }
  755.  
  756.     /* Sprite1 */
  757.     if ( (sprite_ptr = (char huge *)halloc(  65535, 1 ))  == NULL )
  758.         {
  759.         set_mode( 3 );
  760.         printf( "\nMemory allocation error for sprite.\n" );
  761.         exit( 2 );
  762.         }
  763.  
  764.     if ( _dos_open("poohsp.twk", O_RDONLY, &file_handle) )
  765.         {
  766.         set_mode( 3 );
  767.         printf("\nUnable to open sprite. \n" );
  768.         exit( 2 );
  769.          }
  770.     else
  771.         {
  772.         _dos_read( file_handle, sprite_ptr,     10, &ammount_read);    /* header */
  773.         width  = (ui) *(sprite_ptr + 4);
  774.         height = (ui) *(sprite_ptr + 6);
  775.         height &= 0x00ff;
  776.  
  777.         _dos_read( file_handle, sprite_ptr,    768, &ammount_read);
  778.         _dos_read( file_handle, sprite_ptr,  65535, &ammount_read);
  779.         _dos_close(file_handle);
  780.         }
  781.  
  782.  
  783.  
  784.     do_background(backgnd_ptr);        /* background on page1 */
  785.     switch_pages_poll();
  786.     do_background(backgnd_ptr);        /* background on page2 */
  787.  
  788.     prev_row = 0;
  789.     prev_col = 0;
  790.     for (x1=250,y1=150;    y1>10;    x1-=1,y1-=1) /* next sprite */
  791.         {
  792.         erase_sprite( prev_col, prev_row, width, height, backgnd_ptr );
  793.         draw_sprite( x1,y1, width, height, sprite_ptr);
  794.         switch_pages_poll();
  795.         erase_sprite( prev_col, prev_row, width, height, backgnd_ptr );
  796.         draw_sprite( x1,y1, width, height, sprite_ptr);
  797.         switch_pages_poll();
  798.        prev_row = y1;
  799.        prev_col = x1;
  800.         }
  801.  
  802.  
  803.         for (i=1; i< 900000; i++)
  804.             ; /* Delay if needed */
  805.  
  806.  
  807. #endif    /* end pooh stuff */
  808.  
  809.  
  810. /* getchar();*/
  811.  
  812.  
  813. set_mode( 3 );
  814.  
  815. printf("\n      Copyright (C) 1991 Fabco \n"); 
  816. printf("\n      EXE file made with:           Fabco's "); 
  817. printf("\n                          Animation/Graphics/Multi-media "); 
  818. printf("\n                                    Toolkit  "); 
  819. printf("\n                                             "); 
  820. printf("\n            available from:     James Faubus "); 
  821. printf("\n                                Rt.1, Box 37 "); 
  822. printf("\n                                Godley, Texas 76044");
  823. printf("\n");
  824.  
  825.  
  826. exit(0);
  827. }
  828.