home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / REND.LZH / REND / CRTX68K.C < prev    next >
C/C++ Source or Header  |  1994-10-05  |  4KB  |  222 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #include <doslib.h>
  5. #include <iocslib.h>
  6.  
  7. #ifdef HIVISION
  8.     extern    int        XPosition, YPosition;
  9. #endif
  10.  
  11. static    int        vline ;
  12.  
  13. void    crtclr( void );
  14.  
  15. #if (defined(REND030))
  16. char    *program = "Do-GA C.G.A System Rendering Program for X68030 & 68882" ;
  17. #elif (defined(RENDXVI))
  18. char    *program = "Do-GA C.G.A System Rendering Program for X68000 & 68881/2" ;
  19. #else
  20. char    *program = "Do-GA C.G.A System Rendering Program for X68000" ;
  21. #endif
  22.  
  23.  
  24. /*    CRTの初期化    */
  25. void    crtinit( line )
  26. int        line ;
  27. {
  28.     vline = line ;
  29.     CRTMOD( 12 );
  30. }
  31.  
  32. /*    CRTのクリア    */
  33. void    crtclr()
  34. {
  35.     struct    FILLPTR    fill ;
  36.  
  37.     fprintf( stderr, "\x1B[2J" );
  38.     G_CLR_ON() ;
  39. }
  40.  
  41. /*    CRT出力    */
  42. void    crtout( framebuf, xlen, y )
  43. short    *framebuf ;
  44. int        xlen ;
  45. int        y ;
  46. {
  47.     int     i ;
  48.     short    *p, *p2 ;
  49.     int     sp ;
  50. #ifndef RENDXVI
  51.     sp = SUPER( 0 );
  52. #endif
  53.     p = (short *)0xC00000;
  54.  
  55. #ifdef HIVISION
  56.     if (vline <= 256) {
  57.         p += ((YPosition+y) * 512 + XPosition) * 2 ;
  58.         p2 = p + 512 ;
  59.         for (i = xlen ; i > 0; --i)
  60.         {
  61.             *p2++ = *p++ = *framebuf ;
  62.             *p2++ = *p++ = *framebuf++ ;
  63.         }
  64.     } else if (vline <= 512) {
  65.         p += (YPosition + y) * 512 + XPosition;
  66.         for (i = xlen ; i > 0; --i)
  67.             *p++ = *framebuf++ ;
  68.     } else if (vline <= 1024) {
  69.         if (y % 2 == 0) {
  70.             p += (YPosition + y) * 256 + XPosition/2;
  71.             for (i = xlen/2 ; i > 0; --i) {
  72.                 *p++ = *framebuf++ ;
  73.                 framebuf++;
  74.             }
  75.         }
  76.     } else if (vline <= 2048) {
  77.         if (y % 4 == 0) {
  78.             p += (YPosition + y) * 128 + XPosition/4;
  79.             for (i = xlen/4; i > 0; --i) {
  80.                 *p++ = *framebuf;
  81.                 framebuf+=4;
  82.             }
  83.         }
  84.     }
  85. #else
  86.     if ( vline == 512 )
  87.     {
  88.         p += y * 512;
  89.         for( i = 0 ; i < xlen ; ++i )
  90.             *p++ = *framebuf++ ;
  91.     }
  92.     else
  93.     {
  94.         p += y * 1024;
  95.         p2 = p + 512 ;
  96.             for( i = 0 ; i < xlen ; ++i )
  97.         {
  98.             *p2++ = *p++ = *framebuf ;
  99.             *p2++ = *p++ = *framebuf++ ;
  100.         }
  101.     }
  102. #endif
  103.  
  104. #ifndef RENDXVI
  105.     STACK_ADJUST:
  106.     SUPER( sp );
  107. #endif
  108. }
  109.  
  110. void    crtline( x1, y1, x2, y2 )
  111. int        x1, y1, x2, y2 ;
  112. {
  113.     struct    LINEPTR line ;
  114. #ifdef HIVISION
  115.     x1 += XPosition;
  116.     y1 += YPosition;
  117.     x2 += XPosition;
  118.     y2 += YPosition;
  119. #endif
  120. #ifndef HIVISION
  121.     if ( vline == 256 )
  122.     {
  123.         line.x1 = x1 * 2 ;
  124.         line.y1 = y1 * 2 ;
  125.         line.x2 = x2 * 2 ;
  126.         line.y2 = y2 * 2 ;
  127.     }
  128.     else
  129.     {
  130.         line.x1 = x1 ;
  131.         line.y1 = y1 ;
  132.         line.x2 = x2 ;
  133.         line.y2 = y2 ;
  134.     }
  135. #else
  136.     if (vline <= 256) {
  137.         line.x1 = x1 * 2 ;
  138.         line.y1 = y1 * 2 ;
  139.         line.x2 = x2 * 2 ;
  140.         line.y2 = y2 * 2 ;
  141.     } else if (vline <= 512) {
  142.         line.x1 = x1 ;
  143.         line.y1 = y1 ;
  144.         line.x2 = x2 ;
  145.         line.y2 = y2 ;
  146.     } else if (vline <= 1024) {
  147.         line.x1 = x1 / 2 ;
  148.         line.y1 = y1 / 2 ;
  149.         line.x2 = x2 / 2 ;
  150.         line.y2 = y2 / 2 ;
  151.     } else if (vline <= 2048) {
  152.         line.x1 = x1 / 4 ;
  153.         line.y1 = y1 / 4 ;
  154.         line.x2 = x2 / 4 ;
  155.         line.y2 = y2 / 4 ;
  156.     }
  157. #endif
  158.  
  159.     line.color = 0xFFFF ;
  160.     line.linestyle = 0xFFFF ;
  161.  
  162.     LINE( &line );
  163. }
  164.  
  165. #ifdef WIREVIEW
  166. void    crtlinecolor( x1, y1, x2, y2, color )
  167. int        x1, y1, x2, y2 ;
  168. unsigned short color;
  169. {
  170.     struct    LINEPTR line ;
  171. #ifdef HIVISION
  172.     x1 += XPosition;
  173.     y1 += YPosition;
  174.     x2 += XPosition;
  175.     y2 += YPosition;
  176. #endif
  177. #ifndef HIVISION
  178.     if ( vline == 256 )
  179.     {
  180.         line.x1 = x1 * 2 ;
  181.         line.y1 = y1 * 2 ;
  182.         line.x2 = x2 * 2 ;
  183.         line.y2 = y2 * 2 ;
  184.     }
  185.     else
  186.     {
  187.         line.x1 = x1 ;
  188.         line.y1 = y1 ;
  189.         line.x2 = x2 ;
  190.         line.y2 = y2 ;
  191.     }
  192. #else
  193.     if (vline <= 256) {
  194.         line.x1 = x1 * 2 ;
  195.         line.y1 = y1 * 2 ;
  196.         line.x2 = x2 * 2 ;
  197.         line.y2 = y2 * 2 ;
  198.     } else if (vline <= 512) {
  199.         line.x1 = x1 ;
  200.         line.y1 = y1 ;
  201.         line.x2 = x2 ;
  202.         line.y2 = y2 ;
  203.     } else if (vline <= 1024) {
  204.         line.x1 = x1 / 2 ;
  205.         line.y1 = y1 / 2 ;
  206.         line.x2 = x2 / 2 ;
  207.         line.y2 = y2 / 2 ;
  208.     } else if (vline <= 2048) {
  209.         line.x1 = x1 / 4 ;
  210.         line.y1 = y1 / 4 ;
  211.         line.x2 = x2 / 4 ;
  212.         line.y2 = y2 / 4 ;
  213.     }
  214. #endif
  215.  
  216.     line.color = color;
  217.     line.linestyle = 0xFFFF ;
  218.  
  219.     LINE( &line );
  220. }
  221. #endif
  222.