Merge branch 'fix_mm1_video' of git://github.com/kara1001000/mame into kara1001000-fix_mm1_video

This commit is contained in:
cracyc 2015-10-10 19:52:23 -05:00
commit 95154b19d1
3 changed files with 63 additions and 34 deletions

View File

@ -373,6 +373,18 @@ inline void upd7220_device::update_blank_timer(int state)
}
//-------------------------------------------------
// static_set_visarea - configuration helper to
// set the visible area of the screen that is
// used by recompute_parameters()
//-------------------------------------------------
void upd7220_device::static_set_visible_area_offsets(device_t &device, INT16 dminx, INT16 dmaxx, INT16 dminy, INT16 dmaxy)
{
downcast<upd7220_device &>(device).m_visarea_offset.set(dminx, dmaxx, dminy, dmaxy);
}
//-------------------------------------------------
// recompute_parameters -
//-------------------------------------------------
@ -393,36 +405,30 @@ inline void upd7220_device::recompute_parameters()
int horiz_pix_total = (m_hs + m_hbp + m_hfp + m_aw) * horiz_mult;
int vert_pix_total = (m_vs + m_vbp + m_al + m_vfp) * vert_mult;
//printf("%d %d %d %d\n",m_hs,m_hbp,m_aw,m_hfp);
//printf("%d %d\n",m_aw * 8,m_pitch * 8);
if (horiz_pix_total == 0 || vert_pix_total == 0) //bail out if screen params aren't valid
return;
attoseconds_t refresh = HZ_TO_ATTOSECONDS(clock() * 8) * horiz_pix_total * vert_pix_total;
rectangle visarea;
visarea.min_x = 0; //(m_hs + m_hbp) * 8;
visarea.min_y = m_vbp; //m_vs + m_vbp;
visarea.max_x = m_aw * horiz_mult - 1;//horiz_pix_total - (m_hfp * 8) - 1;
visarea.max_y = m_al * vert_mult + m_vbp - 1;//vert_pix_total - m_vfp - 1;
visarea.min_x = m_visarea_offset.min_x; //(m_hs + m_hbp) * 8;
visarea.min_y = m_vbp + m_visarea_offset.min_y; // setting this to m_vbp by default; this works at least for pc9801 software (e.g. Dragon Buster) that uses vbp to offset the slave 7220 start line from the master
visarea.max_x = m_aw * horiz_mult - 1 + m_visarea_offset.max_x; //horiz_pix_total - (m_hfp * 8) - 1;
visarea.max_y = m_al * vert_mult + m_vbp - 1 + m_visarea_offset.max_y; //vert_pix_total - m_vfp - 1;
LOG(("uPD7220 '%s' Screen: %u x %u @ %f Hz\n", tag(), horiz_pix_total, vert_pix_total, 1 / ATTOSECONDS_TO_DOUBLE(refresh)));
LOG(("Visible Area: (%u, %u) - (%u, %u)\n", visarea.min_x, visarea.min_y, visarea.max_x, visarea.max_y));
LOG(("%d %d %d %d %d\n",m_hs,m_hbp,m_aw,m_hfp,m_pitch));
LOG(("%d %d %d %d\n",m_vs,m_vbp,m_al,m_vfp));
LOG(("hs=%d hbp=%d aw=%d hfp=%d pitch=%d hmult=%d htot=%d\n", m_hs, m_hbp, m_aw, m_hfp, m_pitch, horiz_mult, horiz_pix_total));
LOG(("vs=%d vbp=%d al=%d vfp=%d vmult=%d vtot=%d\n", m_vs, m_vbp, m_al, m_vfp, vert_mult, vert_pix_total));
if (m_m)
{
m_screen->configure(horiz_pix_total, vert_pix_total, visarea, refresh);
update_hsync_timer(0);
update_vsync_timer(0);
}
else
{
m_screen->configure(horiz_pix_total, vert_pix_total, visarea, refresh);
m_hsync_timer->enable(0);
m_vsync_timer->enable(0);
}
@ -635,6 +641,7 @@ upd7220_device::upd7220_device(const machine_config &mconfig, const char *tag, d
m_hs(0),
m_hfp(0),
m_hbp(0),
m_visarea_offset(0, 0, 0, 0),
m_dc(0),
m_sc(0),
m_br(0),
@ -1607,11 +1614,8 @@ void upd7220_device::update_graphics(bitmap_rgb32 &bitmap, const rectangle &clip
for (area = 0; area < 4; area++)
{
get_graphics_partition(area, &sad, &len, &im, &wd);
if (im || force_bitmap)
{
//get_graphics_partition(area, &sad, &len, &im, &wd);
if(area >= 3) // TODO: most likely to be correct, Quarth (PC-98xx) definitely draws with area 2. We might see an area 3 someday ...
break;

View File

@ -64,6 +64,8 @@
#define MCFG_UPD7220_BLANK_CALLBACK(_write) \
devcb = &upd7220_device::set_blank_wr_callback(*device, DEVCB_##_write);
#define MCFG_UPD7220_VISIBLE_AREA_OFFSET(_dminx, _dmaxx, _dminy, _dmaxy) \
upd7220_device::static_set_visible_area_offsets(*device, _dminx, _dmaxx, _dminy, _dmaxy);
//**************************************************************************
@ -86,6 +88,7 @@ public:
static void static_set_display_pixels_callback(device_t &device, upd7220_display_pixels_delegate callback) { downcast<upd7220_device &>(device).m_display_cb = callback; }
static void static_set_draw_text_callback(device_t &device, upd7220_draw_text_delegate callback) { downcast<upd7220_device &>(device).m_draw_text_cb = callback; }
static void static_set_visible_area_offsets(device_t &device, INT16 dminx, INT16 dmaxx, INT16 dminy, INT16 dmaxy);
template<class _Object> static devcb_base &set_drq_wr_callback(device_t &device, _Object object) { return downcast<upd7220_device &>(device).m_write_drq.set_callback(object); }
template<class _Object> static devcb_base &set_hsync_wr_callback(device_t &device, _Object object) { return downcast<upd7220_device &>(device).m_write_hsync.set_callback(object); }
@ -194,6 +197,8 @@ private:
int m_hfp; // horizontal front porch width - 1
int m_hbp; // horizontal back porch width - 1
rectangle m_visarea_offset; // device dependend visible area offsets for xmin, ymin, xmax and ymax
int m_dc; // display cursor
int m_sc; // 0 = blinking cursor / 1 = steady cursor
int m_br; // blink rate

View File

@ -2,7 +2,7 @@
// copyright-holders:Curt Coder
#include "includes/mikromik.h"
#define HORIZONTAL_CHARACTER_PIXELS 10
//-------------------------------------------------
// i8275 crtc display pixels
@ -12,24 +12,43 @@ I8275_DRAW_CHARACTER_MEMBER( mm1_state::crtc_display_pixels )
{
UINT8 romdata = m_char_rom->base()[(charcode << 4) | linecount];
int gpa0 = BIT(gpa, 0); // general purpose attribute 0
int llen = m_llen; // light enable
int compl_in = rvv; // reverse video
int hlt_in = hlgt; // highlight;
int color; // 0 = black, 1 = dk green, 2 = lt green; on MikroMikko 1, "highlight" is actually the darker shade of green
int i, qh, video_in;
int d7 = BIT(romdata, 7); // save MSB (1 indicates that this is a Visual Attribute or Special Code instead of a normal display character)
int d6 = BIT(romdata, 6); // save also first and last char bitmap bits before shifting out the MSB
int d0 = BIT(romdata, 0);
int d7 = BIT(romdata, 7);
int gpa0 = BIT(gpa, 0);
int llen = m_llen;
int i;
UINT8 data = (romdata << 1) | (d7 & d0); // get rid of MSB, duplicate LSB for special characters
UINT8 data = (romdata << 1) | (d7 & d0);
for (i = 0; i < 8; i++)
if (y < 360 || x >= HORIZONTAL_CHARACTER_PIXELS || compl_in == 0) // leftmost char on the 25th row is never displayed on actual MikroMikko 1 HW if it's inversed
{
int qh = BIT(data, i);
int video_in = ((((d7 & llen) | !vsp) & !gpa0) & qh) | lten;
int compl_in = rvv;
int hlt_in = hlgt;
if (HORIZONTAL_CHARACTER_PIXELS == 10)
{
// Hack to stretch 8 pixels wide character bitmap to 10 pixels on screen.
// This was needed because high res graphics use 800 pixels wide bitmap but
// 80 chars * 8 pixels is only 640 -> characters would cover only 80% of the screen width.
// Step 1: Instead of 8, set MCFG_I8275_CHARACTER_WIDTH(10) at the end of this file
// Step 2: Make sure i8275_device::recompute_parameters() is called in i8275_device::device_start()
// Step 3: Fill in missing 2 pixels in the screen bitmap by repeating last column of the char bitmap
// (works better with MikroMikko 1 font than duplicating the first and the last column)
qh = d7 & d6; // extend pixels on the right side only if there were two adjacent ones before shifting out the MSB
video_in = ((((d7 & llen) | !vsp) & !gpa0) & qh) | lten;
color = (hlt_in ? 1 : 2)*(video_in ^ compl_in);
bitmap.pix32(y, x + 8) = m_palette->pen(color);
bitmap.pix32(y, x + 9) = m_palette->pen(color);
}
int color = hlt_in ? 2 : (video_in ^ compl_in);
bitmap.pix32(y, x + i) = m_palette->pen(color);
for (i = 0; i < 8; ++i) // ...and now the actual character bitmap bits for this scanline
{
qh = BIT(data, i);
video_in = ((((d7 & llen) | !vsp) & !gpa0) & qh) | lten;
color = (hlt_in ? 1 : 2)*(video_in ^ compl_in);
bitmap.pix32(y, x + i) = m_palette->pen(color);
}
}
}
@ -105,15 +124,15 @@ MACHINE_CONFIG_FRAGMENT( mm1m6_video )
MCFG_SCREEN_ADD( SCREEN_TAG, RASTER )
MCFG_SCREEN_REFRESH_RATE( 50 )
MCFG_SCREEN_UPDATE_DRIVER(mm1_state, screen_update)
MCFG_SCREEN_SIZE( 800, 400 )
MCFG_SCREEN_VISIBLE_AREA( 0, 800-1, 0, 400-1 )
MCFG_SCREEN_SIZE( 800, 375 ) // (25 text rows * 15 vertical pixels / character)
MCFG_SCREEN_VISIBLE_AREA( 0, 800-1, 0, 375-1 )
//MCFG_SCREEN_RAW_PARAMS(XTAL_18_720MHz, ...)
MCFG_GFXDECODE_ADD("gfxdecode", "palette", mm1)
MCFG_PALETTE_ADD_MONOCHROME_GREEN_HIGHLIGHT("palette")
MCFG_DEVICE_ADD(I8275_TAG, I8275, XTAL_18_720MHz/8)
MCFG_I8275_CHARACTER_WIDTH(8)
MCFG_I8275_CHARACTER_WIDTH(HORIZONTAL_CHARACTER_PIXELS)
MCFG_I8275_DRAW_CHARACTER_CALLBACK_OWNER(mm1_state, crtc_display_pixels)
MCFG_I8275_DRQ_CALLBACK(DEVWRITELINE(I8237_TAG, am9517a_device, dreq0_w))
MCFG_I8275_VRTC_CALLBACK(DEVWRITELINE(UPD7220_TAG, upd7220_device, ext_sync_w))
@ -122,5 +141,6 @@ MACHINE_CONFIG_FRAGMENT( mm1m6_video )
MCFG_DEVICE_ADD(UPD7220_TAG, UPD7220, XTAL_18_720MHz/8)
MCFG_DEVICE_ADDRESS_MAP(AS_0, mm1_upd7220_map)
MCFG_UPD7220_DISPLAY_PIXELS_CALLBACK_OWNER(mm1_state, hgdc_display_pixels)
MCFG_UPD7220_VISIBLE_AREA_OFFSET(0, 0, -25, 23) // match the visible area of I8275 output
MCFG_VIDEO_SET_SCREEN(SCREEN_TAG)
MACHINE_CONFIG_END