home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / REND.LZH / REND / CRTV70.C < prev    next >
C/C++ Source or Header  |  1992-07-29  |  2KB  |  141 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. char    *program = "Do-GA C.G.A System Rendering Program for V70 on X68000" ;
  16.  
  17.  
  18. /*    CRTの初期化    */
  19. void    crtinit( line )
  20. int        line ;
  21. {
  22.     vline = line ;
  23.     CRTMOD( 12 );
  24. }
  25.  
  26. /*    CRTのクリア    */
  27. void    crtclr()
  28. {
  29.     struct    FILLPTR    fill ;
  30.  
  31.     fprintf( stderr, "\x1B[2J" );
  32.     G_CLR_ON() ;
  33. }
  34.  
  35. unsigned short swapbyte(data)
  36. unsigned short data;
  37. {
  38.     union {
  39.         struct {
  40.             char c1;
  41.             char c2;
  42.         } ch;
  43.         unsigned short sh;
  44.     } swapdata, returndata;
  45.     swapdata.sh = data;
  46.     returndata.ch.c1 = swapdata.ch.c2;
  47.     returndata.ch.c2 = swapdata.ch.c1;
  48.     return returndata.sh;
  49. }
  50.  
  51.  
  52. /*    CRT出力    */
  53. void    crtout( framebuf, xlen, y )
  54. unsigned short    *framebuf ;
  55. int        xlen ;
  56. int        y ;
  57. {
  58.     int     i ;
  59.     unsigned short    *p, *p2 ;
  60.     unsigned short *fbuf;
  61.     static unsigned short pvram[1024];
  62.     unsigned short *pv, *pv2;
  63.     int     sp ;
  64.     struct PUTPTR ptr;
  65.     p = (short *)0xC00000;
  66.     pv = pvram;
  67. #ifndef HIVISION
  68.     if ( vline == 512 )
  69. #else
  70.     if ( vline > 256 )
  71. #endif
  72.     {
  73. #ifdef HIVISION
  74.         p += (YPosition + y) * 512 + XPosition;
  75. #else
  76.         p += y * 512;
  77. #endif
  78.         fbuf = framebuf;
  79.         for( i = 0 ; i < xlen ; ++i )
  80.         {
  81.             *pv++ = swapbyte(*fbuf++);
  82.         }
  83.         B_MEMSET(p, pvram, xlen * 2 - 1);
  84.     }
  85. #ifndef HIVISION
  86.     else if ( vline == 256 )
  87. #else
  88.     else
  89. #endif
  90.     {
  91. #ifdef HIVISION
  92.         p += ((YPosition+y) * 512 + XPosition) * 2 ;
  93. #else
  94.         p += y * 1024;
  95. #endif
  96.         p2 = p + 512 ;
  97.         pv2 = pv + 512;
  98.         fbuf = framebuf;
  99.         for (i = 0; i < xlen; ++i) {
  100.             *pv2++ = *pv2++ = *pv++ = *pv++ = swapbyte(*fbuf++);
  101.         }
  102.         B_MEMSET(p, pvram, xlen * 2 * 2 * 2 - 1);
  103.     }
  104.  
  105. }
  106.  
  107. void    crtline( x1, y1, x2, y2 )
  108. int        x1, y1, x2, y2 ;
  109. {
  110.     struct    LINEPTR line ;
  111. #ifdef HIVISION
  112.     x1 += XPosition;
  113.     y1 += YPosition;
  114.     x2 += XPosition;
  115.     y2 += YPosition;
  116. #endif
  117. #ifndef HIVISION
  118.     if ( vline == 256 )
  119. #else
  120.     if (vline <= 256 )
  121. #endif
  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.  
  136.     line.color = 0xFFFF ;
  137.     line.linestyle = 0xFFFF ;
  138.  
  139.     LINE( &line );
  140. }
  141.