summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/pc6001.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/video/pc6001.cpp')
-rw-r--r--src/mame/video/pc6001.cpp207
1 files changed, 93 insertions, 114 deletions
diff --git a/src/mame/video/pc6001.cpp b/src/mame/video/pc6001.cpp
index 8dcb5121ed0..2874283e3fe 100644
--- a/src/mame/video/pc6001.cpp
+++ b/src/mame/video/pc6001.cpp
@@ -135,9 +135,6 @@ void pc6001sr_state::video_start()
/* this is known as gfx mode 4 */
void pc6001_state::draw_gfx_mode4(bitmap_ind16 &bitmap,const rectangle &cliprect,int attr)
{
- int x,y,xi;
- int fgcol,color;
- int col_setting;
static const uint8_t pen_gattr[4][4] = {
{ 0, 1, 6, 2 }, //Red / Blue
{ 0, 6, 1, 2 }, //Blue / Red
@@ -150,38 +147,38 @@ void pc6001_state::draw_gfx_mode4(bitmap_ind16 &bitmap,const rectangle &cliprect
{ 0, 5, 2, 7 }, //Pink / Green
{ 0, 2, 5, 7 }, //Green / Pink
};
- col_setting = m_io_mode4_dsw->read() & 7;
+ int col_setting = m_io_mode4_dsw->read() & 7;
if((attr & 0x0c) != 0x0c)
popmessage("Mode 4 vram attr != 0x0c, contact MESSdev");
- for(y=0;y<192;y++)
+ for(int y=0;y<192;y++)
{
- for(x=0;x<32;x++)
+ for(int x=0;x<32;x++)
{
int tile = m_video_ram[(x+(y*32))+0x200];
if(col_setting == 0x00) //monochrome
{
- for(xi=0;xi<8;xi++)
+ for(int xi=0;xi<8;xi++)
{
- fgcol = (attr & 2) ? 7 : 2;
+ int fgcol = (attr & 2) ? 7 : 2;
- color = ((tile)>>(7-xi) & 1) ? fgcol : 0;
+ int color = ((tile)>>(7-xi) & 1) ? fgcol : 0;
- bitmap.pix16((y+24), (x*8+xi)+32) = m_palette->pen(color);
+ bitmap.pix((y+24), (x*8+xi)+32) = m_palette->pen(color);
}
}
else
{
- for(xi=0;xi<4;xi++)
+ for(int xi=0;xi<4;xi++)
{
- fgcol = ((tile)>>(6-(xi*2)) & 3);
+ int fgcol = ((tile)>>(6-(xi*2)) & 3);
- color = (attr & 2) ? (pen_wattr[col_setting-1][fgcol]) : (pen_gattr[col_setting-1][fgcol]);
+ int color = (attr & 2) ? (pen_wattr[col_setting-1][fgcol]) : (pen_gattr[col_setting-1][fgcol]);
- bitmap.pix16((y+24), ((x*8+xi*2)+0)+32) = m_palette->pen(color);
- bitmap.pix16((y+24), ((x*8+xi*2)+1)+32) = m_palette->pen(color);
+ bitmap.pix((y+24), ((x*8+xi*2)+0)+32) = m_palette->pen(color);
+ bitmap.pix((y+24), ((x*8+xi*2)+1)+32) = m_palette->pen(color);
}
}
}
@@ -190,8 +187,6 @@ void pc6001_state::draw_gfx_mode4(bitmap_ind16 &bitmap,const rectangle &cliprect
void pc6001_state::draw_bitmap_2bpp(bitmap_ind16 &bitmap,const rectangle &cliprect, int attr)
{
- int color,x,y,xi,yi;
-
int shrink_x = 2*4;
int shrink_y = (attr & 8) ? 1 : 2;
int w = (shrink_x == 8) ? 32 : 16;
@@ -199,22 +194,21 @@ void pc6001_state::draw_bitmap_2bpp(bitmap_ind16 &bitmap,const rectangle &clipre
if(attr & 4)
{
- for(y=0;y<(192/shrink_y);y++)
+ for(int y=0;y<(192/shrink_y);y++)
{
- for(x=0;x<w;x++)
+ for(int x=0;x<w;x++)
{
int tile = m_video_ram[(x+(y*32))+0x200];
- for(yi=0;yi<shrink_y;yi++)
+ for(int yi=0;yi<shrink_y;yi++)
{
- for(xi=0;xi<shrink_x;xi++)
+ for(int xi=0;xi<shrink_x;xi++)
{
- int i;
- i = (shrink_x == 8) ? (xi & 0x06) : (xi & 0x0c)>>1;
- color = ((tile >> i) & 3)+8;
+ int i = (shrink_x == 8) ? (xi & 0x06) : (xi & 0x0c)>>1;
+ int color = ((tile >> i) & 3)+8;
color+= col_bank;
- bitmap.pix16(((y*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = m_palette->pen(color);
+ bitmap.pix(((y*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = m_palette->pen(color);
}
}
}
@@ -222,24 +216,23 @@ void pc6001_state::draw_bitmap_2bpp(bitmap_ind16 &bitmap,const rectangle &clipre
}
else /* TODO: clean this up */
{
- for(y=0;y<(192/shrink_y);y+=3)
+ for(int y=0;y<(192/shrink_y);y+=3)
{
- for(x=0;x<w;x++)
+ for(int x=0;x<w;x++)
{
int tile = m_video_ram[(x+((y/3)*32))+0x200];
- for(yi=0;yi<shrink_y;yi++)
+ for(int yi=0;yi<shrink_y;yi++)
{
- for(xi=0;xi<shrink_x;xi++)
+ for(int xi=0;xi<shrink_x;xi++)
{
- int i;
- i = (shrink_x == 8) ? (xi & 0x06) : (xi & 0x0c)>>1;
- color = ((tile >> i) & 3)+8;
+ int i = (shrink_x == 8) ? (xi & 0x06) : (xi & 0x0c)>>1;
+ int color = ((tile >> i) & 3)+8;
color+= col_bank;
- bitmap.pix16((((y+0)*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = m_palette->pen(color);
- bitmap.pix16((((y+1)*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = m_palette->pen(color);
- bitmap.pix16((((y+2)*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = m_palette->pen(color);
+ bitmap.pix((((y+0)*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = m_palette->pen(color);
+ bitmap.pix((((y+1)*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = m_palette->pen(color);
+ bitmap.pix((((y+2)*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = m_palette->pen(color);
}
}
}
@@ -249,19 +242,17 @@ void pc6001_state::draw_bitmap_2bpp(bitmap_ind16 &bitmap,const rectangle &clipre
void pc6001_state::draw_tile_3bpp(bitmap_ind16 &bitmap,const rectangle &cliprect,int x,int y,int tile,int attr)
{
- int color,pen,xi,yi;
-
+ int pen;
if(attr & 0x10) //2x2 squares on a single cell
pen = (tile & 0x70)>>4;
else //2x3
pen = (tile & 0xc0) >> 6 | (attr & 2)<<1;
- for(yi=0;yi<12;yi++)
+ for(int yi=0;yi<12;yi++)
{
- for(xi=0;xi<8;xi++)
+ for(int xi=0;xi<8;xi++)
{
- int i;
- i = (xi & 4)>>2; //x-axis
+ int i = (xi & 4)>>2; //x-axis
if(attr & 0x10) //2x2
{
i+= (yi >= 6) ? 2 : 0; //y-axis
@@ -272,24 +263,24 @@ void pc6001_state::draw_tile_3bpp(bitmap_ind16 &bitmap,const rectangle &cliprect
i+= (yi & 8)>>1; //y-axis 2
}
- color = ((tile >> i) & 1) ? pen+8 : 0;
+ int color = ((tile >> i) & 1) ? pen+8 : 0;
- bitmap.pix16(((y*12+(11-yi))+24), (x*8+(7-xi))+32) = m_palette->pen(color);
+ bitmap.pix(((y*12+(11-yi))+24), (x*8+(7-xi))+32) = m_palette->pen(color);
}
}
}
void pc6001_state::draw_tile_text(bitmap_ind16 &bitmap,const rectangle &cliprect,int x,int y,int tile,int attr,int has_mc6847)
{
- int xi,yi,pen,fgcol,color;
- uint8_t *gfx_data = m_region_gfx1->base();
+ uint8_t const *const gfx_data = m_region_gfx1->base();
- for(yi=0;yi<12;yi++)
+ for(int yi=0;yi<12;yi++)
{
- for(xi=0;xi<8;xi++)
+ for(int xi=0;xi<8;xi++)
{
- pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1;
+ int pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1;
+ int fgcol,color;
if(has_mc6847)
{
fgcol = (attr & 2) ? 0x12 : 0x10;
@@ -310,19 +301,18 @@ void pc6001_state::draw_tile_text(bitmap_ind16 &bitmap,const rectangle &cliprect
color = pen ? fgcol : 0;
}
- bitmap.pix16(((y*12+yi)+24), (x*8+xi)+32) = m_palette->pen(color);
+ bitmap.pix(((y*12+yi)+24), (x*8+xi)+32) = m_palette->pen(color);
}
}
}
void pc6001_state::draw_border(bitmap_ind16 &bitmap,const rectangle &cliprect,int attr,int has_mc6847)
{
- int x,y,color;
-
- for(y=0;y<240;y++)
+ for(int y=0;y<240;y++)
{
- for(x=0;x<320;x++)
+ for(int x=0;x<320;x++)
{
+ int color;
if(!has_mc6847) //mk2 border color is always black
color = 0;
else if((attr & 0x90) == 0x80) //2bpp
@@ -332,17 +322,14 @@ void pc6001_state::draw_border(bitmap_ind16 &bitmap,const rectangle &cliprect,in
else
color = 0; //FIXME: other modes not yet checked
- bitmap.pix16(y, x) = m_palette->pen(color);
+ bitmap.pix(y, x) = m_palette->pen(color);
}
}
}
void pc6001_state::pc6001_screen_draw(bitmap_ind16 &bitmap,const rectangle &cliprect, int has_mc6847)
{
- int x,y;
- int tile,attr;
-
- attr = m_video_ram[0];
+ int attr = m_video_ram[0];
draw_border(bitmap,cliprect,attr,has_mc6847);
@@ -359,11 +346,11 @@ void pc6001_state::pc6001_screen_draw(bitmap_ind16 &bitmap,const rectangle &clip
}
else // text mode
{
- for(y=0;y<16;y++)
+ for(int y=0;y<16;y++)
{
- for(x=0;x<32;x++)
+ for(int x=0;x<32;x++)
{
- tile = m_video_ram[(x+(y*32))+0x200];
+ int tile = m_video_ram[(x+(y*32))+0x200];
attr = m_video_ram[(x+(y*32)) & 0x1ff];
if(attr & 0x40)
@@ -388,20 +375,16 @@ uint32_t pc6001_state::screen_update_pc6001(screen_device &screen, bitmap_ind16
uint32_t pc6001mk2_state::screen_update_pc6001mk2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
- int x,y,tile,attr;
-
/* note: bitmap mode have priority over everything else, check American Truck */
if(m_exgfx_bitmap_mode)
{
- int count,color,i;
+ int count = 0;
- count = 0;
-
- for(y=0;y<200;y++)
+ for(int y=0;y<200;y++)
{
- for(x=0;x<160;x+=4)
+ for(int x=0;x<160;x+=4)
{
- for(i=0;i<4;i++)
+ for(int i=0;i<4;i++)
{
int pen[2];
#if 0
@@ -417,16 +400,16 @@ uint32_t pc6001mk2_state::screen_update_pc6001mk2(screen_device &screen, bitmap_
pen[0] = m_video_ram[count+0x0000] >> (6-i*2) & 3;
pen[1] = m_video_ram[count+0x2000] >> (6-i*2) & 3;
- color = 0x10;
+ int color = 0x10;
color |= ((pen[0] & 1) << 2);
color |= ((pen[0] & 2) >> 1);
color |= ((pen[1] & 1) << 1);
color |= ((pen[1] & 2) << 2);
if (cliprect.contains((x+i)*2+0, y))
- bitmap.pix16(y, (x+i)*2+0) = m_palette->pen(color);
+ bitmap.pix(y, (x+i)*2+0) = m_palette->pen(color);
if (cliprect.contains((x+i)*2+1, y))
- bitmap.pix16(y, (x+i)*2+1) = m_palette->pen(color);
+ bitmap.pix(y, (x+i)*2+1) = m_palette->pen(color);
}
count++;
@@ -435,15 +418,13 @@ uint32_t pc6001mk2_state::screen_update_pc6001mk2(screen_device &screen, bitmap_
}
else if(m_exgfx_2bpp_mode)
{
- int count,color,i;
-
- count = 0;
+ int count = 0;
- for(y=0;y<200;y++)
+ for(int y=0;y<200;y++)
{
- for(x=0;x<320;x+=8)
+ for(int x=0;x<320;x+=8)
{
- for(i=0;i<8;i++)
+ for(int i=0;i<8;i++)
{
int pen[2];
#if 0
@@ -456,6 +437,7 @@ uint32_t pc6001mk2_state::screen_update_pc6001mk2(screen_device &screen, bitmap_
pen[0] = m_video_ram[count+0x0000] >> (7-i) & 1;
pen[1] = m_video_ram[count+0x2000] >> (7-i) & 1;
+ int color;
if(m_bgcol_bank & 4) //PC-6001 emulation mode
{
color = 0x08;
@@ -472,7 +454,7 @@ uint32_t pc6001mk2_state::screen_update_pc6001mk2(screen_device &screen, bitmap_
}
if (cliprect.contains(x+i, y))
- bitmap.pix16(y, (x+i)) = m_palette->pen(color);
+ bitmap.pix(y, (x+i)) = m_palette->pen(color);
}
count++;
@@ -482,12 +464,11 @@ uint32_t pc6001mk2_state::screen_update_pc6001mk2(screen_device &screen, bitmap_
}
else if(m_exgfx_text_mode)
{
- int xi,yi,pen,fgcol,bgcol,color;
- uint8_t *gfx_data = m_region_gfx1->base();
+ uint8_t const *const gfx_data = m_region_gfx1->base();
- for(y=0;y<20;y++)
+ for(int y=0;y<20;y++)
{
- for(x=0;x<40;x++)
+ for(int x=0;x<40;x++)
{
/*
exgfx attr format:
@@ -496,23 +477,23 @@ uint32_t pc6001mk2_state::screen_update_pc6001mk2(screen_device &screen, bitmap_
---- xxxx fg color
Note that the exgfx banks a different gfx ROM
*/
- tile = m_video_ram[(x+(y*40))+0x400] + 0x200;
- attr = m_video_ram[(x+(y*40)) & 0x3ff];
- tile+= ((attr & 0x80) << 1);
+ int tile = m_video_ram[(x+(y*40))+0x400] + 0x200;
+ int attr = m_video_ram[(x+(y*40)) & 0x3ff];
+ tile += ((attr & 0x80) << 1);
- for(yi=0;yi<12;yi++)
+ for(int yi=0;yi<12;yi++)
{
- for(xi=0;xi<8;xi++)
+ for(int xi=0;xi<8;xi++)
{
- pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1;
+ int pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1;
- fgcol = (attr & 0x0f) + 0x10;
- bgcol = ((attr & 0x70) >> 4) + 0x10 + ((m_bgcol_bank & 2) << 2);
+ int fgcol = (attr & 0x0f) + 0x10;
+ int bgcol = ((attr & 0x70) >> 4) + 0x10 + ((m_bgcol_bank & 2) << 2);
- color = pen ? fgcol : bgcol;
+ int color = pen ? fgcol : bgcol;
if (cliprect.contains(x*8+xi, y*12+yi))
- bitmap.pix16(((y*12+yi)), (x*8+xi)) = m_palette->pen(color);
+ bitmap.pix(((y*12+yi)), (x*8+xi)) = m_palette->pen(color);
}
}
}
@@ -529,35 +510,33 @@ uint32_t pc6001mk2_state::screen_update_pc6001mk2(screen_device &screen, bitmap_
uint32_t pc6001sr_state::screen_update_pc6001sr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
- int x,y,tile,attr;
- int xi,yi,pen,fgcol,bgcol,color;
- uint8_t *gfx_data = m_region_gfx1->base();
+ uint8_t const *const gfx_data = m_region_gfx1->base();
bitmap.fill(0,cliprect);
if(m_sr_text_mode == true) // text mode
{
- for(y=0;y<m_sr_text_rows;y++)
+ for(int y=0;y<m_sr_text_rows;y++)
{
- for(x=0;x<40;x++)
+ for(int x=0;x<40;x++)
{
- tile = m_video_ram[(x+(y*40))*2+0];
- attr = m_video_ram[(x+(y*40))*2+1];
- tile+= ((attr & 0x80) << 1);
+ int tile = m_video_ram[(x+(y*40))*2+0];
+ int attr = m_video_ram[(x+(y*40))*2+1];
+ tile += ((attr & 0x80) << 1);
- for(yi=0;yi<12;yi++)
+ for(int yi=0;yi<12;yi++)
{
- for(xi=0;xi<8;xi++)
+ for(int xi=0;xi<8;xi++)
{
- pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1;
+ int pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1;
- fgcol = (attr & 0x0f) + 0x10;
- bgcol = ((attr & 0x70) >> 4) + 0x10 + ((m_bgcol_bank & 2) << 2);
+ int fgcol = (attr & 0x0f) + 0x10;
+ int bgcol = ((attr & 0x70) >> 4) + 0x10 + ((m_bgcol_bank & 2) << 2);
- color = pen ? fgcol : bgcol;
+ int color = pen ? fgcol : bgcol;
if (cliprect.contains(x*8+xi, y*12+yi))
- bitmap.pix16(((y*12+yi)), (x*8+xi)) = m_palette->pen(color);
+ bitmap.pix(((y*12+yi)), (x*8+xi)) = m_palette->pen(color);
}
}
}
@@ -565,9 +544,9 @@ uint32_t pc6001sr_state::screen_update_pc6001sr(screen_device &screen, bitmap_in
}
else //4bpp bitmap mode (TODO)
{
- for(y=0;y<200;y++)
+ for(int y=0;y<200;y++)
{
- for(x=0;x<320;x+=2)
+ for(int x=0;x<320;x+=2)
{
uint32_t vram_addr;
@@ -576,15 +555,15 @@ uint32_t pc6001sr_state::screen_update_pc6001sr(screen_device &screen, bitmap_in
else
vram_addr = x+y*256;
- color = (m_gvram[vram_addr] & 0xf0) >> 4;
+ int color;
+ color = (m_gvram[vram_addr] & 0xf0) >> 4;
if (cliprect.contains(x, y+0))
- bitmap.pix16((y+0), (x+0)) = m_palette->pen(color+0x10);
+ bitmap.pix((y+0), (x+0)) = m_palette->pen(color+0x10);
color = (m_gvram[vram_addr] & 0x0f);
-
if (cliprect.contains(x+1, y+0))
- bitmap.pix16((y+0), (x+1)) = m_palette->pen(color+0x10);
+ bitmap.pix((y+0), (x+1)) = m_palette->pen(color+0x10);
}
}
}