static void svga_clear_box(int x,int y,int w,int h){ uint8_t * rgbplane; int i; if (mode_capabilities&CAP_ACCEL_CLEAR){ if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with HW acceleration\n", x,y,w,h); if(mode_capabilities&CAP_ACCEL_BACKGR) vga_accel(ACCEL_SYNC); vga_accel(ACCEL_SETFGCOLOR,0);//black vga_accel(ACCEL_FILLBOX,x,y,w,h); return; } if (mode_capabilities & CAP_LINEAR){ if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with memset\n",x,y,w,h); rgbplane=PageStore[0].vbase + (y*mode_stride) + (x*modeinfo->bytesperpixel); for(i=0;i<h;i++){ //i'm afraid that memcpy is better optimized than memset;) fast_memcpy(rgbplane,zerobuf,w*modeinfo->bytesperpixel); // memset(rgbplane,0,w*modeinfo->bytesperpixel); rgbplane+=mode_stride; } return; } //native if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with native draw \n",x,y,w,h); if(modeinfo->bytesperpixel!=0) w*=modeinfo->bytesperpixel; for(i=0;i<h;i++){ vga_drawscansegment(zerobuf,x,y+i,w); } };
void uidisplay_area( int x, int y, int w, int h ) { static unsigned char linebuf[2*DISPLAY_SCREEN_WIDTH]; unsigned char *ptr; float scale; int scaled_x, scaled_y, xx, yy; unsigned char grey = settings_current.bw_tv ? 16 : 0; /* a simplified shortcut, for normal usage */ if ( !hires && image_scale == 1 ) { for( yy = y; yy < y + h; yy++ ) { for( xx = x, ptr = linebuf; xx < x + w; xx++ ) *ptr++ = svgadisplay_image[yy][xx] | grey; vga_drawscansegment( linebuf, x, yy, w ); } return; } scale = (float) ( hires + 1 ) / image_scale; /* Extend the dirty region by 1 pixel for scalers that "smear" the screen, e.g. AdvMAME2x */ if( scaler_flags & SCALER_FLAGS_EXPAND ) scaler_expander( &x, &y, &w, &h, image_width, image_height ); scaled_x = scale * x; scaled_y = scale * y; /* Create scaled image */ scaler_proc16( (libspectrum_byte*)&svgadisplay_image[y][x], svgadisplay_pitch, (libspectrum_byte*)&scaled_image[scaled_y][scaled_x], scaled_pitch, w, h ); w *= scale; h *= scale; for( yy = scaled_y; yy < scaled_y + h; yy++ ) { for( xx = scaled_x, ptr = linebuf; xx < scaled_x + w; xx++ ) *ptr++ = scaled_image[yy][xx] | grey; vga_drawscansegment( linebuf, scaled_x, yy, w ); } }
int main() { ret = init_vga(G320x200x256, VGA, PCI_DEVICE_ID_S3_TRIO64V2); int i; for(i=0;i<64;i++){ vga_setpalette(i, i, i, i); } for(i=0;i<64;i++){ vga_setpalette(i+64, i, 0, 0); } for(i=0;i<64;i++){ vga_setpalette(i+64+64, 0, i, 0); } buffer = (unsigned char *)malloc(VGA_WIDTH*VGA_HEIGHT);//virtual canvas memset(buffer, 0, VGA_WIDTH*VGA_HEIGHT); set_raw_mode(); unsigned int seed = (unsigned) time(NULL); srand(seed); /*srand(seed);rand();*/ float period = 1.0/60.0; //period_ts = double_to_timespec(period); //old versions of MaRTE OS double_to_timespec(period,&period_ts); //new versions of MaRTE OS while(1){ DrawObjects(); //flip vga_drawscansegment(buffer,0,0,VGA_WIDTH*VGA_HEIGHT); nanosleep(&period_ts, NULL); } while(getchar()==-1); return 0; }
static void SVGA_drawpixel(PSD psd,COORD x, COORD y, PIXELVAL c) { unsigned char gline, line; if(gr_mode == MODE_SET) { vga_setegacolor(c); vga_drawpixel(x, y); return; } /* * This fishery is required because vgalib doesn't support * xor drawing mode without acceleration. */ vga_getscansegment(&gline, x, y, 1); line = c; line ^= gline; vga_drawscansegment(&line, x, y, 1); }
void gfx_putimage(unsigned char *image, int xpar, int xsrc, int ysrc, int width, int height, int pitch, int xdst, int ydst) { int x, y; image += ysrc * pitch + xsrc; for (y = 0; y < height; y++) { if (xpar >= 0) { for (x = 0; x < width; x++) if (image[x] != xpar) { vga_setcolor(image[x]); vga_drawpixel(x, y); } } else vga_drawscansegment(image, xdst, ydst + y, width); image += pitch; } }
static void SVGA_drawhline(PSD psd,COORD x1, COORD x2, COORD y, PIXELVAL c) { int i, width; unsigned char getline[640]; static int lastcolor = -1; static int lastwidth = -1; static unsigned char line[640]; /* * All this fishery is required for two reasons: * one, vga_drawline is way too slow to be called to fill * rectangles, so vga_drawscansegment is used instead. In * addition, vgalib doesn't support xor drawing mode * without acceleration!!, so we've got to do it ourselves * with vga_getscansegment... */ width = x2-x1+1; /* this is faster than calling vga_drawline !!!*/ if(width != lastwidth || c != lastcolor) { lastwidth = width; lastcolor = c; for(i=0; i<width; ++i) line[i] = c; } if(gr_mode == MODE_XOR) { vga_getscansegment(getline, x1, y, width); for(i=0; i<width; ++i) line[i] ^= getline[i]; lastwidth = -1; } vga_drawscansegment(line, x1, y, width); /* * Non-fishery version is *slow* and doesn't support XOR. vga_setegacolor(c); vga_drawline(x1, y, x2, y2); */ }
int GGI_svga_puthline(ggi_visual *vis,int x,int y,int w,const void *buffer) { int pixelsize = (LIBGGI_PIXFMT(vis)->size+7)/8; const uint8_t *buf = buffer; LIBGGICLIP_XYW_BUFMOD(vis, x, y, w, buf, *pixelsize); y += vis->w_frame_num * LIBGGI_VIRTY(vis); if (SVGA_PRIV(vis)->ismodex && x%4 != 0) { /* ModeX is always 8bpp */ for (;x%4 != 0; x++,w--) { ggiPutPixel(vis, x, y, *buf); buf++; } for (;w%4 != 0; w--) { ggiPutPixel(vis, x, y, *(buf+w)); } } vga_drawscansegment((uint8_t *)buf, x, y, w*pixelsize); return 0; }
static uint32_t svga_draw_image(mp_image_t *mpi){ int i,x,y,w,h; int stride; uint8_t *rgbplane, *base; int bytesperline; int page; if(mpi->flags & MP_IMGFLAG_DIRECT){ if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: drawing direct rendered surface\n"); cpage=(uint32_t)mpi->priv; assert((cpage>=0)&&(cpage<max_pages)); return VO_TRUE; //it's already done } // if (mpi->flags&MP_IMGFLAGS_DRAWBACK) // return VO_TRUE;//direct render method 2 //find a free page to draw into //if there is no one then use the current one page = page_find_free(); if(page>=0) cpage=page; PageStore[cpage].locks=PAGE_BUSY; // these variables are used in loops x = mpi->x; y = mpi->y; w = mpi->w; h = mpi->h; stride = mpi->stride[0]; rgbplane = mpi->planes[0] + y*stride + (x*mpi->bpp)/8; x+=x_pos;//center y+=y_pos; if(mpi->bpp >= 8){//for modes<8 use only native if( (mode_capabilities&CAP_ACCEL_PUTIMAGE) && (x==0) && (w==mpi->width) && (stride == mode_stride) ){ //only monolite image can be accelerated w=(stride*8)/mpi->bpp;//we transfer pixels in the stride so the source //ACCELERATE if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using HW PutImage (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h); if(mode_capabilities & CAP_ACCEL_BACKGR) vga_accel(ACCEL_SYNC); vga_accel(ACCEL_PUTIMAGE,x,y+PageStore[cpage].yoffset,w,h,rgbplane); return VO_TRUE; } if( mode_capabilities&CAP_LINEAR){ //DIRECT if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Direct memcpy (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h); bytesperline=(w*mpi->bpp)/8; base=PageStore[cpage].vbase + (y*mode_stride) + (x*mpi->bpp)/8; for(i=0;i<h;i++){ mem2agpcpy(base,rgbplane,bytesperline); base+=mode_stride; rgbplane+=stride; } return VO_TRUE; } }//(modebpp>=8 //NATIVE { int length; length=(w*mpi->bpp)/8; //one byte per pixel! svgalib innovation if(mpi->imgfmt==IMGFMT_RG4B || mpi->imgfmt==IMGFMT_BG4B) length=w; if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Native vga_draw(x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h); y+=PageStore[cpage].yoffset;//y position of the page beggining for(i=0;i<h;i++){ vga_drawscansegment(rgbplane,x,y+i,length); rgbplane+=stride; } } return VO_TRUE; }
/*@Function============================================================ @Desc: Diese Prozedur schreibt das im Speicher zusammengebaute Bild in den Bildschirmspeicher. Parameter: keine @Ret: @Int: * $Function----------------------------------------------------------*/ void PutInternFenster (void) { int StartX, StartY; int i; #ifdef DRAW_TO_SCREEN_VARIABLE int j; #endif #ifdef SLOW_VIDEO_CALLS int j; #endif unsigned char *source; unsigned char *target; DebugPrintf ("void PutInternFenster(void) wurde ECHT aufgerufen..."); if (Conceptview) { for (i = 0; i < USERFENSTERHOEHE; i++) { memcpy (RealScreen + (USERFENSTERPOSY + i) * SCREENBREITE + USERFENSTERPOSX, InternWindow + i * INTERNBREITE * BLOCKBREITE, USERFENSTERBREITE); } return; } StartX = (((int) Me.pos.x) % BLOCKBREITE) - BLOCKBREITE / 2; StartY = ((((int) Me.pos.y) % BLOCKHOEHE) - BLOCKHOEHE / 2) * BLOCKBREITE * INTERNBREITE; WaitVRetrace (); // DisplayRahmen ( RealScreen ); Lock_SDL_Screen(); for (i = 0; i < USERFENSTERHOEHE; i++) { source = InternWindow + BLOCKBREITE * (INTERNBREITE - VIEWBREITE) / 2 + INTERNBREITE * BLOCKBREITE * (BLOCKHOEHE * (INTERNHOEHE - VIEWHOEHE)) / 2 + // USERFENSTEROBEN*INTERNBREITE*BLOCKBREITE + // USERFENSTERLINKS + StartY + StartX + i * INTERNBREITE * BLOCKBREITE; target = Outline320x200 + USERFENSTERPOSX + (USERFENSTERPOSY+i) * SCREENBREITE; #define SLOW_VIDEO_CALLS #ifdef SLOW_VIDEO_CALLS #undef DRAW_TO_SCREEN_VARIABLE #ifdef DRAW_TO_SCREEN_VARIABLE for (j = 0; j < USERFENSTERBREITE; j++) { // SDL vga_setcolor (*source); source++; putpixel (screen, USERFENSTERPOSX + j, USERFENSTERPOSY + i, *source ); } // for(j=0; ... #else memcpy(target, source, USERFENSTERBREITE); #endif #else vga_drawscansegment (source, USERFENSTERPOSX, USERFENSTERPOSY + i, USERFENSTERBREITE); // source+=USERFENSTERBREITE; #endif } // for(i=0; ... Unlock_SDL_Screen(); // Update_SDL_Screen(); PrepareScaledSurface(); }; // void PutInternFenster(void)