"Fossies" - the Fresh Open Source Software Archive

Member "alec64-1.13/src/video_go32.h" (16 Jun 1996, 8485 Bytes) of package /linux/misc/old/alec64-1.13.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2 **  The C64 emulator
    3 **
    4 **  Copyright 1996 by ALE.
    5 **  written by Lutz Sammer.
    6 **
    7 **  Video driver for go32 (MSDOS verion of GNU-C)
    8 **-----------------------------------------------------------------------------
    9 ** $Id: video_go32.h,v 1.1 1996/05/01 00:25:57 johns Exp root $
   10 ** $Log: video_go32.h,v $
   11 ** Revision 1.1  1996/05/01 00:25:57  johns
   12 ** Initial revision
   13 **
   14 **-----------------------------------------------------------------------------
   15 */
   16 
   17 #define C64HSIZE    320
   18 #define C64VSIZE    200
   19 
   20 #undef UNIVBE
   21 
   22 #ifdef OVERSCAN
   23 
   24 #ifdef UNIVBE
   25 /*
   26 **  UNIVBE: has a nice video mode 360x400!
   27 */
   28 #define VGAMODE     0x158       /* BIOS graphic mode */
   29 #define HSIZE       512     /* byte_per_line of the video memory */
   30 #define VSIZE       400
   31 #define VADD        68      /* to center emulator */
   32 #define HADD        12      /* to center emulator */
   33 #else
   34 #define VGAMODE     0x101       /* BIOS graphic mode 640x480 */
   35 #define HSIZE       1024        /* byte_per_line of the video memory */
   36 #define VSIZE       400
   37 #define VADD        108     /* to center emulator */
   38 #define HADD        152     /* to center emulator */
   39 #endif
   40 
   41 #else
   42 
   43 #define VGAMODE     0x13        /* BIOS graphic mode */
   44 #define HSIZE       (C64HSIZE)  /* byte_per_line of the video memory */
   45 #define VSIZE       (C64VSIZE)
   46 
   47 #endif
   48 
   49 /*---------------------------------------------------------------------------*/
   50 
   51 extern unsigned char* VideoPointer; /* current pointer in video memory */
   52 #ifdef DPMI
   53 extern unsigned int _core_select;
   54 #define VideoMemory ((unsigned char*)0x000A0000)
   55 #else
   56 #define VideoMemory ((unsigned char*)0xE00A0000)
   57 #endif
   58 
   59 extern void SetOverscanColor(unsigned char);
   60 
   61 /*---------------------------------------------------------------------------*/
   62 
   63 /*
   64 **  Set overscan color.
   65 */
   66 #define VideoSetOverscanColor(color) \
   67     SetOverscanColor(color)
   68 
   69 /*
   70 **  Update internal structures to monitor.
   71 */
   72 #define VideoRefresh()
   73 
   74 /*-----------------------------------------------------------------------------
   75  *  OVERSCAN dependend
   76  *---------------------------------------------------------------------------*/
   77 
   78 #ifdef OVERSCAN /* { */
   79 
   80 /*
   81 **  Called only for blank overscanlines.
   82 */
   83 #define VideoFillOverscanLine(quad_color) \
   84     VideoFillLine(quad_color)
   85 
   86 /*
   87 **  Called only for open border overscanlines.
   88 */
   89 #define VideoCopyOverscanLine(pointer) \
   90     VideoCopyLine(pointer)
   91 
   92 #else   /* }{ OVERSCAN */
   93 
   94 #define VideoFillOverscanLine(quad_color)   /* quad_color */
   95 #define VideoCopyOverscanLine(pointer)      /* pointer */
   96 
   97 #endif  /* } !OVERSCAN */
   98 
   99 /*---------------------------------------------------------------------------*/
  100 
  101 /*
  102 **  1 emulator pixel to video format.
  103 */
  104 #define VIC2VIDEO(p) \
  105     (p)
  106 
  107 #ifdef DPMI /* { */
  108 
  109 /*
  110 **  COMMENT: can't use _farpokeb, didn't get compiled.
  111 */
  112 
  113 /*
  114 **  LongFill version for MSDOS with segment selector.
  115 */
  116 #define dosmemlset(a,v,l) \
  117     asm("
  118     push    %%es
  119     movw    __core_select,%%es  /* Use real area selector */
  120     cld
  121     rep
  122     stosl               /* store ECX bytes to Real area */
  123     pop %%es
  124     " : : "a" (v), "c" (l), "D" (a) : "ax", "cx", "di" )
  125 
  126 /*
  127 **  LongCopy version for MSDOS with segment selector.
  128 */
  129 #define dosmemlmov(d,s,l) \
  130     asm("
  131     push    %%es
  132     movw    __core_select,%%es  /* Use real area selector */
  133     rep
  134     movsl               /* move ECX bytes to Real area */
  135     pop %%es
  136     " : : "S" (s), "D" (d), "c" (l) : "cx", "di", "si")
  137 
  138 #ifdef OVERSCAN /* { */
  139 
  140 extern void setpage(int);
  141 
  142 /*
  143 **  VideoPut: Put a byte into video memory.
  144 */
  145 #define __VideoPut(a,v) \
  146     asm("
  147     push    %%es
  148     movw    __core_select,%%es  /* Use real area selector */
  149     stosb               /* store byte to Real area */
  150     pop %%es
  151     " : : "a" (v), "D" (a) : "ax", "di" )
  152 
  153 /*
  154 **  __VideoLong: Put a long into video memory.
  155 */
  156 #define __VideoLong(a,v) \
  157     asm("
  158     push    %%es
  159     movw    __core_select,%%es  /* Use real area selector */
  160     stosl               /* store byte to Real area */
  161     pop %%es
  162     " : : "a" (v), "D" (a) : "ax", "di" )
  163 
  164 /*
  165 **  Setup ES.
  166 */
  167 #define __VideoSetupES() \
  168     asm("
  169     push    %%es
  170     movw    __core_select,%%es  /* Use real area selector */
  171     " : : )
  172 
  173 /*
  174 **  Restore ES.
  175 */
  176 #define __VideoRestoreES() \
  177     asm("
  178     pop %%es
  179     " : : )
  180 
  181 /*
  182 **  VideoPut: Put a byte into video memory.
  183 */
  184 #define VideoPut(a,v) \
  185   do {                                  \
  186     int __x;                                \
  187     __x=(unsigned)(a)+HADD-(unsigned)VideoMemory;           \
  188     setpage(__x>>16);                           \
  189     __VideoPut(VideoMemory+(__x&0xFFFF),(v));               \
  190   } while( 0 )
  191 
  192 #if 0
  193 /*
  194 **  Fill a scanline with 'quad_color'.
  195 */
  196 #define VideoFillLine(quad_color) \
  197   do {                                  \
  198     int x;                              \
  199     unsigned char* p;                           \
  200     x=VideoPointer-VideoMemory+(VADD*HSIZE)+HADD;           \
  201     p=VideoMemory+(x&0xFFFF);                       \
  202     setpage(x>>16);                         \
  203     __VideoLong(&((unsigned long*)(p))[0],VicExterior);         \
  204     __VideoLong(&((unsigned long*)(p))[1],VicExterior);         \
  205     dosmemlset(p+8,quad_color,C64HSIZE/4);              \
  206     __VideoLong(&((unsigned long*)(p))[2+C64HSIZE/4],VicExterior);  \
  207     __VideoLong(&((unsigned long*)(p))[3+C64HSIZE/4],VicExterior);  \
  208     VideoPointer+=HSIZE;                        \
  209   } while( 0 )
  210 #else
  211 /*
  212 **  Fill a scanline with 'quad_color'.
  213 */
  214 #define VideoFillLine(quad_color) \
  215   do {                                  \
  216     int x;                              \
  217     unsigned char* p;                           \
  218     x=VideoPointer-VideoMemory+(VADD*HSIZE)+HADD;           \
  219     p=VideoMemory+(x&0xFFFF);                       \
  220     setpage(x>>16);                         \
  221     __VideoSetupES();                           \
  222     asm("
  223     movl    _VicExterior,%%eax
  224     stosl
  225     stosl
  226     movl    %0,%%eax
  227     rep
  228     stosl               /* store ECX bytes to Real area */
  229     movl    _VicExterior,%%eax
  230     stosl
  231     stosl
  232     " : : "g" (quad_color), "c" (C64HSIZE/4), "D" (p)       \
  233         : "ax", "cx", "di" );                   \
  234     __VideoRestoreES();                         \
  235     VideoPointer+=HSIZE;                        \
  236   } while( 0 )
  237 
  238 #endif
  239 
  240 #if 0
  241 /*
  242 **  Copy a scanline from 'src' to video.
  243 */
  244 #define VideoCopyLine(src) \
  245   do {                                  \
  246     int x;                              \
  247     unsigned char* p;                           \
  248     x=VideoPointer-VideoMemory+(VADD*HSIZE)+HADD;           \
  249     p=VideoMemory+(x&0xFFFF);                       \
  250     setpage(x>>16);                         \
  251     __VideoLong(&((unsigned long*)(p))[0],VicExterior);         \
  252     __VideoLong(&((unsigned long*)(p))[1],VicExterior);         \
  253     dosmemlmov(p+8,src,C64HSIZE/4);                 \
  254     __VideoLong(&((unsigned long*)(p))[2+C64HSIZE/4],VicExterior);  \
  255     __VideoLong(&((unsigned long*)(p))[3+C64HSIZE/4],VicExterior);  \
  256     VideoPointer+=HSIZE;                        \
  257   } while( 0 )
  258 #else
  259 /*
  260 **  Copy a scanline from 'src' to video.
  261 */
  262 #define VideoCopyLine(src) \
  263   do {                                  \
  264     int x;                              \
  265     unsigned char* p;                           \
  266     x=VideoPointer-VideoMemory+(VADD*HSIZE)+HADD;           \
  267     p=VideoMemory+(x&0xFFFF);                       \
  268     setpage(x>>16);                         \
  269     __VideoSetupES();                           \
  270     asm("
  271     movl    _VicExterior,%%eax
  272     stosl
  273     stosl
  274     rep
  275     movsl               /* move ECX bytes to Real area */
  276     stosl
  277     stosl
  278     " : : "S" (src), "D" (p), "c" (C64HSIZE/4)          \
  279         : "ax", "cx", "di", "si");                  \
  280     __VideoRestoreES();                         \
  281     VideoPointer+=HSIZE;                        \
  282   } while( 0 )
  283 #endif
  284 
  285 
  286 #else   /* }{ OVERSCAN */
  287 
  288 /*
  289 **  VideoPut: Put a byte into video memory.
  290 */
  291 #define VideoPut(a,v) \
  292     asm("
  293     push    %%es
  294     movw    __core_select,%%es  /* Use real area selector */
  295     stosb               /* store byte to Real area */
  296     pop %%es
  297     " : : "a" (v), "D" (a) : "ax", "di" )
  298 
  299 /*
  300 **  Fill a scanline with 'quad_color'.
  301 */
  302 #define VideoFillLine(quad_color) \
  303   do {                                  \
  304     dosmemlset(VideoPointer,quad_color,C64HSIZE/4);         \
  305     VideoPointer+=HSIZE;                        \
  306   } while( 0 )
  307 
  308 /*
  309 **  Copy a scanline from 'src' to video.
  310 */
  311 #define VideoCopyLine(src) \
  312   do {                                  \
  313     dosmemlmov(VideoPointer,src,C64HSIZE/4);                \
  314     VideoPointer+=HSIZE;                        \
  315   } while( 0 )
  316 
  317 #endif  /* } !OVERSCAN */
  318 
  319 #else   /* }{ DPMI */
  320 
  321 /*
  322 **  Fill a scanline with 'quad_color'.
  323 */
  324 #define VideoFillLine(quad_color) \
  325   do {                                  \
  326     LongFill(VideoPointer,quad_color,C64HSIZE/4);           \
  327     VideoPointer+=HSIZE;                        \
  328   } while( 0 )
  329 
  330 /*
  331 **  Copy a scanline from 'src' to video.
  332 */
  333 #define VideoCopyLine(src) \
  334   do {                                  \
  335     LongCopy(VideoPointer,src,C64HSIZE/4);              \
  336     VideoPointer+=HSIZE;                        \
  337   } while( 0 )
  338 
  339 #endif  /* } !DPMI */
  340 
  341 /*-----------------------------------------------------------------------------
  342  *  VIDEOSYNC support
  343  *---------------------------------------------------------------------------*/
  344 
  345 #ifdef VIDEOSYNC    /* { */
  346 
  347 #include <sys/time.h>
  348 #include <unistd.h>
  349 extern long rawclock(void);
  350 
  351 /*
  352 **  Sync video, MSDOS hot polling.
  353 **      BUG ALERT: Modified clock rate 50hz!
  354 */
  355 #define VideoSync() \
  356     do {                        \
  357     static unsigned long y;             \
  358     unsigned long x;                \
  359     if( VideoSyncSpeed ) {              \
  360         do {                    \
  361         x=rawclock();               \
  362         } while( x-y<VicRefreshRate  );     \
  363         y=x;                    \
  364     }                       \
  365     } while( 0 )
  366 
  367 #else   /* }{ VIDEOSYNC */
  368 
  369 #define VideoSync()         /* noop video-sync */
  370 
  371 #endif  /* } !VIDEOSYNC */