summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/fmtowns.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/video/fmtowns.cpp')
-rw-r--r--src/mame/video/fmtowns.cpp94
1 files changed, 39 insertions, 55 deletions
diff --git a/src/mame/video/fmtowns.cpp b/src/mame/video/fmtowns.cpp
index d60da80b198..ef6515700e9 100644
--- a/src/mame/video/fmtowns.cpp
+++ b/src/mame/video/fmtowns.cpp
@@ -975,13 +975,10 @@ void towns_state::render_sprite_16(uint32_t poffset, uint16_t x, uint16_t y, boo
void towns_state::draw_sprites(const rectangle* rect)
{
uint16_t sprite_limit = (m_video.towns_sprite_reg[0] | (m_video.towns_sprite_reg[1] << 8)) & 0x3ff;
- int n;
- uint16_t x,y,attr,colour;
uint16_t xoff = (m_video.towns_sprite_reg[2] | (m_video.towns_sprite_reg[3] << 8)) & 0x1ff;
uint16_t yoff = (m_video.towns_sprite_reg[4] | (m_video.towns_sprite_reg[5] << 8)) & 0x1ff;
uint32_t poffset,coffset;
int linesize = m_video.towns_crtc_reg[24] * 4;
- bool xflip, yflip, xhalfsize, yhalfsize, rotation;
if(!(m_video.towns_sprite_reg[1] & 0x80))
return;
@@ -998,17 +995,17 @@ void towns_state::draw_sprites(const rectangle* rect)
for(int i = linesize; i < 0x20000; i += linesize)
memcpy(vram + i, vram, linesize);
- for(n=sprite_limit;n<1024;n++)
+ for(int n=sprite_limit;n<1024;n++)
{
- x = m_towns_txtvram[8*n] | (m_towns_txtvram[8*n+1] << 8);
- y = m_towns_txtvram[8*n+2] | (m_towns_txtvram[8*n+3] << 8);
- attr = m_towns_txtvram[8*n+4] | (m_towns_txtvram[8*n+5] << 8);
- colour = m_towns_txtvram[8*n+6] | (m_towns_txtvram[8*n+7] << 8);
- xflip = (attr & 0x2000) >> 13;
- yflip = (attr & 0x1000) >> 12;
- rotation = (attr & 0x4000) >> 14;
- xhalfsize = (attr & 0x400) >> 10;
- yhalfsize = (attr & 0x800) >> 11;
+ uint16_t x = m_towns_txtvram[8*n] | (m_towns_txtvram[8*n+1] << 8);
+ uint16_t y = m_towns_txtvram[8*n+2] | (m_towns_txtvram[8*n+3] << 8);
+ uint16_t attr = m_towns_txtvram[8*n+4] | (m_towns_txtvram[8*n+5] << 8);
+ uint16_t colour = m_towns_txtvram[8*n+6] | (m_towns_txtvram[8*n+7] << 8);
+ bool xflip = (attr & 0x2000) >> 13;
+ bool yflip = (attr & 0x1000) >> 12;
+ bool rotation = (attr & 0x4000) >> 14;
+ bool xhalfsize = (attr & 0x400) >> 10;
+ bool yhalfsize = (attr & 0x800) >> 11;
if(attr & 0x8000)
{
@@ -1053,12 +1050,10 @@ void towns_state::draw_sprites(const rectangle* rect)
void towns_state::towns_crtc_draw_scan_layer_hicolour(bitmap_rgb32 &bitmap,const rectangle* rect,int layer,int line,int scanline)
{
uint32_t off = 0;
- int x;
uint16_t colour;
int hzoom = 1;
int linesize;
uint32_t scroll;
- int pixel;
int page = 0;
bool sphscroll = !(m_video.towns_crtc_reg[28] & (layer ? 0x20 : 0x10));
@@ -1111,7 +1106,7 @@ void towns_state::towns_crtc_draw_scan_layer_hicolour(bitmap_rgb32 &bitmap,const
off += line * linesize;
off &= ~1;
- for(x=rect->min_x;x<rect->max_x;x+=hzoom)
+ for(int x=rect->min_x;x<rect->max_x;x+=hzoom)
{
int offpage;
int curoff;
@@ -1128,8 +1123,8 @@ void towns_state::towns_crtc_draw_scan_layer_hicolour(bitmap_rgb32 &bitmap,const
colour = (m_towns_gfxvram[curoff+(offpage*0x40000)+1] << 8) | m_towns_gfxvram[curoff+(offpage*0x40000)];
if(!(m_video.towns_video_reg[0] & 0x10) || (m_video.towns_video_reg[1] & 0x01) != layer || colour < 0x8000)
{
- for (pixel = 0; pixel < hzoom; pixel++)
- bitmap.pix32(scanline, x+pixel) =
+ for (int pixel = 0; pixel < hzoom; pixel++)
+ bitmap.pix(scanline, x+pixel) =
((colour & 0x001f) << 3)
| ((colour & 0x7c00) << 1)
| ((colour & 0x03e0) << 14);
@@ -1143,12 +1138,10 @@ void towns_state::towns_crtc_draw_scan_layer_hicolour(bitmap_rgb32 &bitmap,const
void towns_state::towns_crtc_draw_scan_layer_256(bitmap_rgb32 &bitmap,const rectangle* rect,int line,int scanline)
{
int off = 0;
- int x;
uint8_t colour;
int hzoom = 1;
int linesize;
uint32_t scroll;
- int pixel;
int page = 0;
bool sphscroll = !(m_video.towns_crtc_reg[28] & 0x10);
@@ -1174,12 +1167,12 @@ void towns_state::towns_crtc_draw_scan_layer_256(bitmap_rgb32 &bitmap,const rect
off += (subpix >> 1) & ~3;
subpix = subpix & 7;
- for(x=rect->min_x;x<rect->max_x;x+=hzoom)
+ for(int x=rect->min_x;x<rect->max_x;x+=hzoom)
{
off &= 0x3ffff;
colour = m_towns_gfxvram[off+(subpix >= 4 ? (subpix & 3)+0x40000 : subpix)];
- for (pixel = 0; pixel < hzoom; pixel++)
- bitmap.pix32(scanline, x+pixel) = m_palette->pen(colour);
+ for (int pixel = 0; pixel < hzoom; pixel++)
+ bitmap.pix(scanline, x+pixel) = m_palette->pen(colour);
subpix++;
if(subpix == 8)
{
@@ -1194,12 +1187,8 @@ void towns_state::towns_crtc_draw_scan_layer_256(bitmap_rgb32 &bitmap,const rect
void towns_state::towns_crtc_draw_scan_layer_16(bitmap_rgb32 &bitmap,const rectangle* rect,int layer,int line,int scanline)
{
int off = 0;
- int x;
- uint8_t colour;
int hzoom = 1;
- int linesize;
uint32_t scroll;
- int pixel;
int page = 0;
palette_device* pal = m_palette16[layer];
bool sphscroll = !(m_video.towns_crtc_reg[28] & (layer ? 0x20 : 0x10));
@@ -1215,6 +1204,7 @@ void towns_state::towns_crtc_draw_scan_layer_16(bitmap_rgb32 &bitmap,const recta
// if((layer == 1) && (m_video.towns_sprite_reg[1] & 0x80) && (m_video.towns_sprite_page == 1))
// off = 0x20000;
+ int linesize;
if(layer == 0)
linesize = m_video.towns_crtc_reg[20] * 4;
else
@@ -1249,23 +1239,24 @@ void towns_state::towns_crtc_draw_scan_layer_16(bitmap_rgb32 &bitmap,const recta
off += line * linesize;
- for(x=rect->min_x;x<rect->max_x;x+=hzoom*2)
+ for(int x=rect->min_x;x<rect->max_x;x+=hzoom*2)
{
if(m_video.towns_video_reg[0] & 0x10)
off &= 0x3ffff; // 2 layers
else
off &= 0x7ffff; // 1 layer
+ uint8_t colour;
colour = m_towns_gfxvram[off+(layer*0x40000)] >> 4;
if(colour != 0 || bottom_layer)
{
- for (pixel = 0; pixel < hzoom; pixel++)
- bitmap.pix32(scanline, x+hzoom+pixel) = pal->pen(colour);
+ for (int pixel = 0; pixel < hzoom; pixel++)
+ bitmap.pix(scanline, x+hzoom+pixel) = pal->pen(colour);
}
colour = m_towns_gfxvram[off+(layer*0x40000)] & 0x0f;
if(colour != 0 || bottom_layer)
{
- for (pixel = 0; pixel < hzoom; pixel++)
- bitmap.pix32(scanline, x+pixel) = pal->pen(colour);
+ for (int pixel = 0; pixel < hzoom; pixel++)
+ bitmap.pix(scanline, x+pixel) = pal->pen(colour);
}
off++;
if ((off - (page * 0x20000)) % linesize == 0 && sphscroll)
@@ -1275,7 +1266,6 @@ void towns_state::towns_crtc_draw_scan_layer_16(bitmap_rgb32 &bitmap,const recta
void towns_state::towns_crtc_draw_layer(bitmap_rgb32 &bitmap,const rectangle* rect,int layer)
{
- int line;
int scanline;
int bottom;
int top;
@@ -1294,7 +1284,7 @@ void towns_state::towns_crtc_draw_layer(bitmap_rgb32 &bitmap,const rectangle* re
switch(m_video.towns_video_reg[0] & 0x03)
{
case 0x01:
- for(line=top;line<=bottom;line++)
+ for(int line=top;line<=bottom;line++)
{
do
{
@@ -1306,7 +1296,7 @@ void towns_state::towns_crtc_draw_layer(bitmap_rgb32 &bitmap,const rectangle* re
}
break;
case 0x02:
- for(line=top;line<=bottom;line++)
+ for(int line=top;line<=bottom;line++)
{
do
{
@@ -1318,7 +1308,7 @@ void towns_state::towns_crtc_draw_layer(bitmap_rgb32 &bitmap,const rectangle* re
}
break;
case 0x03:
- for(line=top;line<=bottom;line++)
+ for(int line=top;line<=bottom;line++)
{
do
{
@@ -1343,7 +1333,7 @@ void towns_state::towns_crtc_draw_layer(bitmap_rgb32 &bitmap,const rectangle* re
switch(m_video.towns_video_reg[0] & 0x0c)
{
case 0x04:
- for(line=top;line<=bottom;line++)
+ for(int line=top;line<=bottom;line++)
{
do
{
@@ -1355,7 +1345,7 @@ void towns_state::towns_crtc_draw_layer(bitmap_rgb32 &bitmap,const rectangle* re
}
break;
case 0x0c:
- for(line=top;line<=bottom;line++)
+ for(int line=top;line<=bottom;line++)
{
do
{
@@ -1376,11 +1366,7 @@ void towns_state::render_text_char(uint8_t x, uint8_t y, uint8_t ascii, uint16_t
uint32_t vram_addr;
uint16_t linesize = m_video.towns_crtc_reg[24] * 4;
uint8_t code_h,code_l;
- uint8_t colour;
- uint8_t data;
- uint8_t temp;
uint8_t* font_rom = m_user->base();
- int a,b;
// all characters are 16 pixels high
vram_addr = (x * 4) + (y * (linesize * 16));
@@ -1415,29 +1401,27 @@ void towns_state::render_text_char(uint8_t x, uint8_t y, uint8_t ascii, uint16_t
| 0x38000;
}
}
- colour = attr & 0x07;
+ uint8_t colour = attr & 0x07;
if(attr & 0x20)
colour |= 0x08;
- for(a=0;a<16;a++) // for each scanline
+ for(int a=0;a<16;a++) // for each scanline
{
+ uint8_t data;
if((attr & 0xc0) == 0)
data = font_rom[0x180000 + rom_addr + a];
+ else if((attr & 0xc0) == 0x80)
+ data = font_rom[0x180000 + rom_addr + (a*2)];
else
- {
- if((attr & 0xc0) == 0x80)
- data = font_rom[0x180000 + rom_addr + (a*2)];
- else
- data = font_rom[0x180000 + rom_addr + (a*2) + 1];
- }
+ data = font_rom[0x180000 + rom_addr + (a*2) + 1];
if(attr & 0x08)
data = ~data; // inverse
// and finally, put the data in VRAM
- for(b=0;b<8;b+=2)
+ for(int b=0;b<8;b+=2)
{
- temp = 0;
+ uint8_t temp = 0;
if(data & (1<<b))
temp |= ((colour & 0x0f) << 4);
if(data & (1<<(b+1)))
@@ -1469,11 +1453,11 @@ void towns_state::draw_text_layer()
*
* The video hardware renders text to VRAM layer 1, there is no separate text layer
*/
- int x,y,c = 0;
+ int c = 0;
- for(y=0;y<40;y++)
+ for(int y=0;y<40;y++)
{
- for(x=0;x<80;x++)
+ for(int x=0;x<80;x++)
{
render_text_char(x,y,m_towns_txtvram[c],((m_towns_txtvram[c+0x2000] << 8)|(m_towns_txtvram[c+0x2001])),m_towns_txtvram[c+1]);
c+=2;