home *** CD-ROM | disk | FTP | other *** search
/ FreeWare Collection 2 / FreeSoftwareCollection2pd199x-jp.img / manboetc / manbo.c < prev    next >
Text File  |  1990-06-14  |  2KB  |  114 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <egb.h>
  4. #include <mos.h>
  5.  
  6. #define NUM 96
  7.  
  8. struct    FISH    {
  9.                     short    x ;
  10.                     short    y ;
  11.                     char    icon ;
  12.                     signed char    dir ;
  13.                     char    color ;
  14.             } ;
  15.  
  16. #define work mwork+2560
  17.  
  18. char    mwork[4096] ;
  19. struct    FISH fish[NUM] ;
  20.  
  21. void main()
  22. {
  23.     extern    void setFish(struct FISH *) ;
  24.     extern    void moveFish() ;
  25.     extern    void dispFish() ;
  26.  
  27.     int        i ;
  28. /*
  29.     EGB_init(work,1536) ;
  30.     EGB_resolution(work,0,0x3) ;
  31.     EGB_resolution(work,1,0x3) ;
  32.     EGB_writePage(work,0x0) ;
  33.     EGB_displayPage(work,0,3) ;
  34. */
  35.     EGB_resolution(work,0,0x43) ;
  36.     EGB_resolution(work,1,0x43) ;
  37.     EGB_writePage(work,0x40) ;
  38.  
  39.     for (i = 0 ; i < NUM ; i++)
  40.         setFish(&fish[i]) ;
  41.  
  42.     EGB_writeMode(work,4) ;
  43.     moveFish() ;
  44.     dispFish() ;
  45. }
  46.  
  47. void moveFish()
  48. {
  49.     extern    void setFish(struct FISH *) ;
  50.  
  51.     int        i = 0 ;
  52.     int        ch,x,y ;
  53.     char    para[64] ;
  54.  
  55.     MOS_start(mwork,4096) ;
  56.  
  57.     do
  58.     {
  59.         EGB_color(work,0,fish[i].color) ;
  60.         DWORD(para + 0) = 0x28000+fish[i].icon*256 ;
  61.         WORD(para + 4) = 0x108 ;
  62.         WORD(para + 6) = fish[i].x+fish[i].dir ;
  63.         WORD(para + 8) = fish[i].y ;
  64.         WORD(para + 10) = fish[i].x+31+fish[i].dir ;
  65.         WORD(para + 12) = fish[i].y+31 ;
  66.         EGB_putBlockColor(work,0,para) ;
  67.         WORD(para + 6) = fish[i].x ;
  68.         WORD(para + 10) = fish[i].x+31 ;
  69.         EGB_putBlockColor(work,0,para) ;
  70.  
  71.         fish[i].x += fish[i].dir ;
  72.  
  73.         if (fish[i].x < -32)
  74.             setFish(&fish[i]) ;
  75.  
  76.         i++ ;
  77.         if (i == NUM) i = 0 ;
  78.         MOS_rdpos(&ch,&x,&y) ;
  79.     } while (!ch) ;
  80.     MOS_end() ;
  81. }
  82.  
  83. void dispFish()
  84. {
  85.     int        i ;
  86.     char    para[64] ;
  87.  
  88.     for (i = 0 ; i < NUM ; i++)
  89.     {
  90.         EGB_color(work,0,fish[i].color) ;
  91.         DWORD(para + 0) = 0x28000+fish[i].icon*256 ;
  92.         WORD(para + 4) = 0x108 ;
  93.         WORD(para + 6) = fish[i].x ;
  94.         WORD(para + 8) = fish[i].y ;
  95.         WORD(para + 10) = fish[i].x+31 ;
  96.         WORD(para + 12) = fish[i].y+31 ;
  97.         EGB_putBlockColor(work,0,para) ;
  98.     }
  99. }
  100.  
  101. void setFish(data)
  102. struct FISH *data ;
  103. {
  104.     int        spd ;
  105.  
  106.     spd = (rand() & 0xf)+1 ;
  107.  
  108.     data->x = 640 ;
  109.     data->y = rand() & 0x1ff ;
  110.     data->icon = 40 ;
  111.     data->dir = -spd ;
  112.     data->color = rand() & 0xf ;
  113. }
  114.