/* 320, 2 bits per pixel */ static void pcw16_vh_decode_mode1(mame_bitmap *bitmap, int x, int y, unsigned char byte) { int b; int px; int local_byte; int cols[4]; for (b=0; b<3; b++) { cols[b] = Machine->pens[pcw16_colour_palette[b]]; } local_byte = byte; px = x; for (b=0; b<4; b++) { int col; col = cols[((local_byte>>6) & 0x03)]; plot_pixel(bitmap, px, y, col); px++; plot_pixel(bitmap, px, y, col); px++; local_byte = local_byte<<2; } }
static void draw_line(mame_bitmap *bitmap, int x1, int y1, int x2, int y2, int dotted) { /* Draws horizontal and Vertical lines only! */ int col = Machine->pens[1]; int count, skip; /* Draw the Line */ if (dotted > 0) skip = 2; else skip = 1; if (x1 == x2) { for (count = y2; count >= y1; count -= skip) { plot_pixel(bitmap, x1, count, col); } } else { for (count = x2; count >= x1; count -= skip) { plot_pixel(bitmap, count, y1, col); } } }
void line_slow(int x1, int y1, int x2, int y2, byte color) { int dx,dy,sdx,sdy,px,py,dxabs,dyabs,i; float slope; dx=x2-x1; /* the horizontal distance of the line */ dy=y2-y1; /* the vertical distance of the line */ dxabs=abs(dx); dyabs=abs(dy); sdx=sgn(dx); sdy=sgn(dy); if (dxabs>=dyabs) /* the line is more horizontal than vertical */ { slope=(float)dy / (float)dx; for(i=0;i!=dx;i+=sdx) { px=i+x1; py=slope*i+y1; plot_pixel(px,py,color); } } else /* the line is more vertical than horizontal */ { slope=(float)dx / (float)dy; for(i=0;i!=dy;i+=sdy) { px=slope*i+x1; py=i+y1; plot_pixel(px,py,color); } } }
static void pdp1_draw_circle(mame_bitmap *bitmap, int x, int y, int radius, int color) { float fx, fy; float interval; fx = (float)x*crt_window_width/01777; fy = (float)y*crt_window_height/01777; interval = radius/sqrt(2); for (x=/*ceil*/(fx-interval); x<=fx+interval; x++) { float dy = sqrt(radius*radius-(x-fx)*(x-fx)); if ((x >= 0) && (x <= crt_window_width-1) && (fy-dy >= 0)) plot_pixel(bitmap, x, fy-dy, color); if ((x >= 0) && (x <= crt_window_width-1) && (y+dy <= crt_window_height-1)) plot_pixel(bitmap, x, fy+dy, color); } for (y=/*ceil*/(fy-interval); y<=fy+interval; y++) { float dx = sqrt(radius*radius-(y-fy)*(y-fy)); if ((fx-dx >= 0) && (y >= 0) && (y <= crt_window_height-1)) plot_pixel(bitmap, fx-dx, y, color); if ((fx+dx <= crt_window_width-1) && (y >= 0) && (y <= crt_window_height-1)) plot_pixel(bitmap, fx+dx, y, color); } }
void graphics_bitmap( struct graphics *g, int32_t x, int32_t y, int32_t width, int32_t height, uint8_t *data ) { int i,j,b; int value; width = MIN(g->clip.w-x,width); height = MIN(g->clip.h-y,height); x += g->clip.x; y += g->clip.y; b=0; for(j=0;j<height;j++) { for(i=0;i<width;i++) { value = ((*data)<<b)&0x80; if(value) { plot_pixel(g->bitmap,x+i,y+j,g->fgcolor); } else { plot_pixel(g->bitmap,x+i,y+j,g->bgcolor); } b++; if(b==8) { data++; b=0; } } } }
/* 160, 4 bits per pixel */ static void pcw16_vh_decode_mode2(mame_bitmap *bitmap, int x, int y, unsigned char byte) { int px; int b; int local_byte; int cols[2]; cols[0] = Machine->pens[pcw16_colour_palette[0]]; cols[1] = Machine->pens[pcw16_colour_palette[1]]; local_byte = byte; px = x; for (b=0; b<2; b++) { int col; col = cols[((local_byte>>4)&0x0f)]; plot_pixel(bitmap, px, y, col); px++; plot_pixel(bitmap, px, y, col); px++; plot_pixel(bitmap, px, y, col); px++; plot_pixel(bitmap, px, y, col); px++; local_byte = local_byte<<4; } }
static void draw_grid(mame_bitmap *bitmap) { const UINT8 *table = memory_region(REGION_GFX3); int x,y,counter; counter = flip_screen ? 0x000 : 0x400; x = Machine->screen[0].visarea.min_x; y = Machine->screen[0].visarea.min_y; while (y <= Machine->screen[0].visarea.max_y) { x = 4 * (table[counter] & 0x7f); if (x >= Machine->screen[0].visarea.min_x && x <= Machine->screen[0].visarea.max_x) { if (table[counter] & 0x80) /* star */ { if (rand() & 1) /* noise coming from sound board */ plot_pixel(bitmap,x,y,Machine->pens[256]); } else if (grid_on) /* radar */ plot_pixel(bitmap,x,y,Machine->pens[257]); } counter++; if (x >= 4 * (table[counter] & 0x7f)) y++; } }
static void z88_vh_render_6x8(mame_bitmap *bitmap, int x, int y, int pen0, int pen1, unsigned char *pData) { int h,b; for (h=0; h<8; h++) { UINT8 data; data = pData[h]; data = data<<2; for (b=0; b<6; b++) { int pen; if (data & 0x080) { pen = pen1; } else { pen = pen0; } plot_pixel(bitmap, x+1+b, y+h, pen); data = data<<1; } plot_pixel(bitmap,x,y+h, pen0); plot_pixel(bitmap,x+7,y+h, pen0); } }
static void update_smoothing(int bgtilerow, int first, int last) { UINT8 *prom = memory_region(REGION_PROMS) + smooth_table * 0x100; UINT8 bgscan[2][256]; UINT8 *bgcurr = bgscan[0], *bglast = bgscan[1]; int xstart, xstop, x, y; /* smoothing notes: * even scanlines blend the previous (Y-1) and current (Y) line * odd scanlines are just taken from the current line (Y) * therefore, if we modify source scanlines 8-15, we must update dest scanlines 16-32 * even pixels are just taken from the current pixel (X) * odd pixels blend the current (X) and next (X+1) pixels * therefore, if we modify source pixels 8-15, we must update dest pixels 15-31 */ /* compute x start/stop in destination coordinates */ xstart = first * 16 - 1; xstop = last * 16 + 15; /* extract the previous bg scanline */ extract_scanline8(bgbitmap, 0, ((bgtilerow * 16 - 1) & 0x1ff) / 2, 256, bgcurr); /* loop over height */ for (y = 0; y <= 16; y++) { int curry = (bgtilerow * 16 + y) & 0x1ff; /* swap background buffers */ UINT8 *bgtemp = bgcurr; bgcurr = bglast; bglast = bgtemp; /* extract current bg scanline */ extract_scanline8(bgbitmap, 0, curry / 2, 256, bgcurr); /* loop over columns */ for (x = xstart; x <= xstop; x++) { int tr = bglast[((x + 1) & 0x1ff) / 2]; int br = bgcurr[((x + 1) & 0x1ff) / 2]; /* smooth pixels */ if (x & 1) { int tl = bglast[(x & 0x1ff) / 2]; int bl = bgcurr[(x & 0x1ff) / 2]; int mixt = prom[16 * tl + tr]; int mixb = prom[16 * bl + br]; plot_pixel(bgexbitmap, x & 0x1ff, curry, prom[0x400 + 16 * mixt + mixb]); } else plot_pixel(bgexbitmap, x & 0x1ff, curry, prom[0x400 + 16 * tr + br]); } } }
static void cdp1869_draw_line(mame_bitmap *bitmap, int x, int y, int data, int pcb) { int i; int color = 0; int ccb0 = (data & 0x40) >> 6; int ccb1 = (data & 0x80) >> 7; switch (cdp1869.col) { case 0: color = (ccb0 << 2) + (ccb1 << 1) + pcb; break; case 1: color = (ccb0 << 2) + (pcb << 1) + ccb1; break; case 2: case 3: color = (pcb << 2) + (ccb0 << 1) + ccb1; break; } data <<= 2; for (i = 0; i < CDP1870_CHAR_WIDTH; i++) { if (data & 0x80) { plot_pixel(bitmap, x, y, Machine->pens[color]); if (!cdp1869.fresvert) { plot_pixel(bitmap, x, y + 1, Machine->pens[color]); } if (!cdp1869.freshorz) { x++; plot_pixel(bitmap, x, y, Machine->pens[color]); if (!cdp1869.fresvert) { plot_pixel(bitmap, x, y + 1, Machine->pens[color]); } } } x++; data <<= 1; } }
static void refresh_bitmaps(void) { int lx,ly; for (ly = 0; ly < 256; ly++) { for (lx = 0; lx < 256; lx++) { plot_pixel(tmpbitmap, (lx-6)&0xff, ly, Machine->pens[16 + tmpvideoram[ly*256+lx]]); plot_pixel(tmpbitmap2, (lx-6)&0xff, ly, Machine->pens[16 + tmpvideoram2[ly*256+lx]]); } } }
static void pdp1_draw_circle(mame_bitmap *bitmap, int x, int y, int radius, int color_) { int interval; int a; x = x*crt_window_width/01777; y = y*crt_window_width/01777; radius = radius*crt_window_width/01777; interval = ceil(radius/sqrt(2)); for (a=0; a<=interval; a++) { int b = sqrt(radius*radius-a*a) + .5; if ((x-a >= 0) && (y-b >= 0)) plot_pixel(bitmap, x-a, y-b, color_); if ((x-a >= 0) && (y+b <= crt_window_height-1)) plot_pixel(bitmap, x-a, y+b, color_); if ((x+a <= crt_window_width-1) && (y-b >= 0)) plot_pixel(bitmap, x+a, y-b, color_); if ((x+a <= crt_window_width-1) && (y+b <= crt_window_height-1)) plot_pixel(bitmap, x+a, y+b, color_); if ((x-b >= 0) && (y-a >= 0)) plot_pixel(bitmap, x-b, y-a, color_); if ((x-b >= 0) && (y+a <= crt_window_height-1)) plot_pixel(bitmap, x-b, y+a, color_); if ((x+b <= crt_window_width-1) && (y-a >= 0)) plot_pixel(bitmap, x+b, y-a, color_); if ((x+b <= crt_window_width-1) && (y+a <= crt_window_height-1)) plot_pixel(bitmap, x+b, y+a, color_); } }
static WRITE_HANDLER( findout_bitmap_w ) { int sx,sy; int fg,bg,mask,bits; fg = drawctrl[0] & 7; bg = 2; mask = 0xff;//drawctrl[2]; bits = drawctrl[1]; sx = 8*(offset % 64); sy = offset / 64; //if (mask != bits) // usrintf_showmessage("color %02x bits %02x mask %02x\n",fg,bits,mask); if (mask & 0x80) plot_pixel(tmpbitmap,sx+0,sy,(bits & 0x80) ? fg : bg); if (mask & 0x40) plot_pixel(tmpbitmap,sx+1,sy,(bits & 0x40) ? fg : bg); if (mask & 0x20) plot_pixel(tmpbitmap,sx+2,sy,(bits & 0x20) ? fg : bg); if (mask & 0x10) plot_pixel(tmpbitmap,sx+3,sy,(bits & 0x10) ? fg : bg); if (mask & 0x08) plot_pixel(tmpbitmap,sx+4,sy,(bits & 0x08) ? fg : bg); if (mask & 0x04) plot_pixel(tmpbitmap,sx+5,sy,(bits & 0x04) ? fg : bg); if (mask & 0x02) plot_pixel(tmpbitmap,sx+6,sy,(bits & 0x02) ? fg : bg); if (mask & 0x01) plot_pixel(tmpbitmap,sx+7,sy,(bits & 0x01) ? fg : bg); }
static WRITE8_HANDLER( getrivia_bitmap_w ) { int sx,sy; int fg,bg,mask,bits; static int prevoffset, yadd; videoram[offset] = data; yadd = (offset==prevoffset) ? (yadd+1):0; prevoffset = offset; fg = drawctrl[0] & 7; bg = 2; mask = 0xff;/*drawctrl[2]; */ bits = drawctrl[1]; sx = 8 * (offset % 64); sy = offset / 64; sy = (sy + yadd) & 0xff; /*if (mask != bits) */ /* ui_popup("color %02x bits %02x mask %02x\n",fg,bits,mask); */ if (mask & 0x80) plot_pixel(tmpbitmap,sx+0,sy,(bits & 0x80) ? fg : bg); if (mask & 0x40) plot_pixel(tmpbitmap,sx+1,sy,(bits & 0x40) ? fg : bg); if (mask & 0x20) plot_pixel(tmpbitmap,sx+2,sy,(bits & 0x20) ? fg : bg); if (mask & 0x10) plot_pixel(tmpbitmap,sx+3,sy,(bits & 0x10) ? fg : bg); if (mask & 0x08) plot_pixel(tmpbitmap,sx+4,sy,(bits & 0x08) ? fg : bg); if (mask & 0x04) plot_pixel(tmpbitmap,sx+5,sy,(bits & 0x04) ? fg : bg); if (mask & 0x02) plot_pixel(tmpbitmap,sx+6,sy,(bits & 0x02) ? fg : bg); if (mask & 0x01) plot_pixel(tmpbitmap,sx+7,sy,(bits & 0x01) ? fg : bg); }
/* used in hires and text mode */ static void oric_vh_render_6pixels(mame_bitmap *bitmap,int x,int y, int fg, int bg,int data, int invert_flag) { int i; int pens[2]; int px; /* invert? */ if (invert_flag) { fg ^=0x07; bg ^=0x07; } pens[1] = Machine->pens[fg]; pens[0] = Machine->pens[bg]; px = x; for (i=0; i<6; i++) { int col; col = pens[(data>>5) & 0x01]; plot_pixel(bitmap,px, y, col); px++; data = data<<1; } }
static void draw_headlights( struct mame_bitmap *bitmap, const struct rectangle *cliprect, int bFog ) { int sx, sy, color; int x0 = 256-grchamp_player_xpos-64; int y0 = 240-grchamp_player_ypos-64; const UINT8 *source = memory_region( REGION_GFX4 ); int x,y,bit; if( !bFog ) source += 0x400; for( y=0; y<128; y++ ) { for( x=0; x<64; x+=8 ) { int data = *source++; if( data ) { for( bit=0; bit<8; bit++ ) { if( data&0x80 ){ sx = x0+x+bit; sy = y0+y; if( sx>=cliprect->min_x && sy>=cliprect->min_y && sx<=cliprect->max_x && sy<=cliprect->max_y ) { color = read_pixel( headlight_bitmap, x+bit, y ); plot_pixel( bitmap, sx,sy, color ); } } data <<= 1; } } } } }
static void aim65_draw_7segment(mame_bitmap *bitmap,int value, int x, int y) { int i, xi, yi, mask, color; for (i=0, xi=0, yi=0; led[i]; i++) { mask=0; switch (led[i]) { case 'a': mask=1; break; case 'b': mask=2; break; case 'c': mask=4; break; case 'd': mask=8; break; case 'e': mask=0x10; break; case 'f': mask=0x20; break; case 'g': mask=0x40; break; case 'h': mask=0x80; break; case 'i': mask=0x100; break; case 'j': mask=0x200; break; case 'k': mask=0x400; break; case 'l': mask=0x800; break; case 'm': mask=0x1000; break; case 'n': mask=0x2000; break; case 'o': mask=0x4000; break; case 'p': mask=0x8000; break; } if (mask!=0) { color=Machine->pens[(value&mask)?1:0]; plot_pixel(bitmap, x+xi, y+yi, color); } if (led[i]!='\r') xi++; else { yi++, xi=0; } } }
static void ssystem3_draw_7segment(mame_bitmap *bitmap,int value, int x, int y) { int i, xi, yi, mask, color; for (i=0, xi=0, yi=0; led[i]; i++) { mask=0; switch (led[i]) { case 'a': mask=1; break; case 'b': mask=2; break; case 'c': mask=4; break; case 'd': mask=8; break; case 'e': mask=0x10; break; case 'f': mask=0x20; break; case 'g': mask=0x40; break; case 'h': // this is more likely wired to the separate leds mask=0x80; break; } if (mask!=0) { color=Machine->pens[(value&mask)?1:0]; plot_pixel(bitmap, x+xi, y+yi, color); } if (led[i]!='\r') xi++; else { yi++, xi=0; } } }
static void superqix_draw_bitmap( struct mame_bitmap *bitmap ) { int i; UINT8 pens[16]; pens[0]=0; for (i=1; i<16; i++) pens[i]=Machine->pens[i]; if (sqix_current_bitmap==0) /* Bitmap 1 */ { int x,y; for (y = sqix_miny;y <= sqix_maxy;y++) { for (x = sqix_minx;x <= sqix_maxx;x++) { int sx,sy,d; if (superqix_bitmapram_dirty[y*128+x]) { superqix_bitmapram_dirty[y*128+x]=0; d = superqix_bitmapram[y*128+x]; sx = 2*x; sy = y+16; plot_pixel(tmpbitmap2, sx , sy, pens[d >> 4]); plot_pixel(tmpbitmap2, sx + 1, sy, pens[d & 0x0f]); } } } }
/* draw a small 8*8 LED (or is this a lamp? ) */ static void pdp1_draw_led(mame_bitmap *bitmap, int x, int y, int state) { int xx, yy; for (yy=1; yy<7; yy++) for (xx=1; xx<7; xx++) plot_pixel(bitmap, x+xx, y+yy, Machine->pens[state ? pen_lit_lamp : pen_unlit_lamp]); }
static inline void graphics_line_hozo( struct graphics *g, int32_t x, int32_t y, int32_t w, int32_t h ) { do { plot_pixel(g->bitmap,x,y,g->fgcolor); x++; w--; } while(w>0); }
static inline void graphics_line_vert( struct graphics *g, int32_t x, int32_t y, int32_t w, int32_t h ) { do { plot_pixel(g->bitmap,x,y,g->fgcolor); y++; h--; } while(h>0); }
void line_fast(int x1, int y1, int x2, int y2, byte color) { int i,dx,dy,sdx,sdy,dxabs,dyabs,x,y,px,py; dx=x2-x1; /* the horizontal distance of the line */ dy=y2-y1; /* the vertical distance of the line */ dxabs=abs(dx); dyabs=abs(dy); sdx=sgn(dx); sdy=sgn(dy); x=dyabs>>1; y=dxabs>>1; px=x1; py=y1; VGA[(py<<8)+(py<<6)+px]=color; if (dxabs>=dyabs) /* the line is more horizontal than vertical */ { for(i=0;i<dxabs;i++) { y+=dyabs; if (y>=dxabs) { y-=dxabs; py+=sdy; } px+=sdx; plot_pixel(px,py,color); } } else /* the line is more vertical than horizontal */ { for(i=0;i<dyabs;i++) { x+=dxabs; if (x>=dyabs) { x-=dyabs; px+=sdx; } py+=sdy; plot_pixel(px,py,color); } } }
static void z88_vh_render_line(mame_bitmap *bitmap, int x, int y,int pen) { plot_pixel(bitmap, x, y+7, pen); plot_pixel(bitmap, x+1, y+7, pen); plot_pixel(bitmap, x+2, y+7, pen); plot_pixel(bitmap, x+3, y+7, pen); plot_pixel(bitmap, x+4, y+7, pen); plot_pixel(bitmap, x+5, y+7, pen); plot_pixel(bitmap, x+6, y+7, pen); plot_pixel(bitmap, x+7, y+7, pen); }
static void plot_pixel_8080_tmpbitmap (int x, int y, int col) { if (flip_screen) { x = 255-x; y = 223-y; } plot_pixel(tmpbitmap,x,y,Machine->pens[col]); }
INLINE void kangaroo_plot_pixel(struct osd_bitmap *bitmap, int x, int y, int col, int color_base, int flip) { if (flip) { x = bitmap->width - 1 - x; y = bitmap->height - 1 - y; } plot_pixel(bitmap, x, y, Machine->pens[((col & 0x08) ? 0 : color_base) + (col & 0x07)]); }
static void draw_sky(mame_bitmap *bitmap) { int x,y; for (y = 0;y < 256;y++) { for (x = 0;x < 256;x++) { plot_pixel(bitmap,x,y,Machine->pens[128 + x/2]); } } }
void z88_state::vh_render_6x8(bitmap_ind16 &bitmap, int x, int y, UINT16 pen0, UINT16 pen1, UINT8 *gfx) { for (int h=0; h<8; h++) { UINT8 data = gfx[h]<<2; for (int b=0; b<6; b++) { plot_pixel(bitmap, x+1+b, y+h, (data & 0x80) ? pen1 : pen0); data = data<<1; } } }
static int collision_check( mame_bitmap *bitmap, int which ) { int bgcolor = Machine->pens[0]; int sprite_transp = Machine->pens[0x24]; const rectangle *clip = &Machine->visible_area; int y0 = 240-grchamp_player_ypos; int x0 = 256-grchamp_player_xpos; int x,y,sx,sy; int pixel; int result = 0; if( which==0 ) { /* draw the current player sprite into a work bitmap */ drawgfx( work_bitmap, Machine->gfx[2], grchamp_tile_number&0xf, 1, /* color */ 0,0, 0,0, 0, TRANSPARENCY_NONE, 0 ); } for( y = 0; y <32; y++ ) { for( x = 0; x<32; x++ ) { pixel = read_pixel(work_bitmap,x,y); if( pixel != sprite_transp ){ sx = x+x0; sy = y+y0; if( (sx >= clip->min_x) && (sx <= clip->max_x) && (sy >= clip->min_y) && (sy <= clip->max_y) ) { /* Collision check uses only 16 pens! */ pixel = read_pixel(bitmap, sx, sy) % 16; if( pixel != bgcolor ) { result = 1; /* flag collision */ /* wipe this pixel, so collision checks with the ** next layer work */ plot_pixel( bitmap, sx, sy, bgcolor ); } } } } } return result?(1<<which):0; }
void scanline(Point *P, int size, byte color){ int minY, maxY; int scan; int i; int x,y; int *countBuffer; Point *pointBuffer; int pointBuffSize = 0; /*Init buffer*/ countBuffer = (int*)malloc(sizeof(int) * size); pointBuffer = (Point*)malloc(sizeof(Point) * size); /*First part - make the envelope*/ minY = minPointY(P, size).y; maxY = maxPointY(P, size).y; /*Second part - loop scanline*/ scan = minY; while(scan <= maxY){ /*Counting the polarity of each lines*/ for(i=0;i<size;i++){ countBuffer[i] = P[i].y - scan; } /*See which points are intersecting with the scanline*/ for(i=0;i<size;i++){ if((countBuffer[i] > 0 && countBuffer[(i+1) % size] < 0)||(countBuffer[i] < 0 && countBuffer[(i+1) % size] > 0)){ pointBuffer[pointBuffSize].x = getIntersectionX(P[i],P[(i+1) % size],scan); pointBuffer[pointBuffSize].y = scan; pointBuffSize = pointBuffSize + 1; } } /*Sort the points*/ pointBuffer = sortPointX(pointBuffer,pointBuffSize); /*Drawing the line*/ for(i=0;i<pointBuffSize;i+=2){ x = pointBuffer[i].x + 1; y = scan; while(x < pointBuffer[i+1].x){ plot_pixel(x,y,color); x = x + 1; } } pointBuffSize = 0; scan++; } }