home *** CD-ROM | disk | FTP | other *** search
/ Cine Clips / Cine Clips.iso / extras / oregan / basicaof / examples / _parallax / c / parallax
Encoding:
Text File  |  1995-09-12  |  2.1 KB  |  73 lines

  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4. #include "kernel.h"
  5. #include "swis.h"
  6. #include "parallax.h"
  7.  
  8. static int f[33];
  9. static void *pic[4] =
  10. {
  11.         picture0,
  12.         picture1,
  13.         picture2,
  14.         picture3
  15. };
  16. /*==================================================================*/
  17. static void paint_background(void)
  18. {
  19.         static int h[14]={-68,40,  -4,19,  -4,9, -3,6,  73,  2,3,5 ,10,10, };
  20.         static int s[14]={ 0 , 6,   0, 4,   0,3,  0,2,   4,  5,8,16,24,32, };
  21.         int i, y=0;
  22.         for (i=0; i<14; i++)
  23.         {
  24.                 if (h[i]>0)
  25.                 {
  26.                         int f2,wh,wid;
  27.                         f2=f[s[i]]>>5;
  28.                         wh=(f[s[i]]>>3) &3;
  29.                         wid=80-f2;
  30.                         blitstripe(0, f2, wid, y, h[i], pic[wh] );
  31.                         if (wid<80) blitstripe(wid+0, 0, 80-wid,y, h[i], pic[wh] );
  32.  
  33.                         y +=h[i];
  34.                 } else
  35.                         y -=h[i];
  36.         }
  37.         for (i=1;i<33;i++)
  38.         {
  39.                 f[i] +=i;
  40.                 if (f[i]>=2560) f[i] -=2560;
  41.         }
  42. }
  43. /*==================================================================*/
  44. static void initialise(void)
  45. {
  46.         _kernel_swi_regs arm;
  47.         int block[]={ 148, 150, -1};
  48.         _kernel_swi(OS_WriteI + 22, &arm, &arm);
  49.         _kernel_swi(OS_WriteI + 13, &arm, &arm);
  50.         _kernel_swi(OS_RemoveCursors, &arm, &arm);
  51.         arm.r[0] = (int)block;
  52.         arm.r[1] = (int)block;
  53.         _kernel_swi(OS_ReadVduVariables, &arm, &arm);
  54.         screenbase  = block[0];
  55.         if (block[1] < 80*1024)
  56.         {
  57.                 fprintf(stderr, "At least 80k screen memory needed\n");
  58.                 exit(1);
  59.         }
  60. }
  61. /*==================================================================*/
  62. int main(void)
  63. {
  64.         initialise();
  65.         blitstripe(0, 0, 80, 0, 256, pic[0] );
  66.         while (!_kernel_escape_seen())
  67.         {
  68.                 paint_background();
  69.                 _kernel_osbyte(19,0,0);
  70.         }
  71. }
  72. /*==================================================================*/
  73.