z88: more light cleanup, nw

This commit is contained in:
mooglyguy 2018-06-09 00:07:06 +02:00
parent c8e2d9504e
commit e76e13a3a2
2 changed files with 41 additions and 62 deletions

View File

@ -611,12 +611,12 @@ MACHINE_CONFIG_START(z88_state::z88)
m_screen->set_palette(m_palette); m_screen->set_palette(m_palette);
MCFG_SCREEN_UPDATE_DEVICE("blink", upd65031_device, screen_update) MCFG_SCREEN_UPDATE_DEVICE("blink", upd65031_device, screen_update)
MCFG_PALETTE_ADD(m_palette, Z88_NUM_COLOURS) device = &PALETTE(config, m_palette, Z88_NUM_COLOURS);
MCFG_PALETTE_INIT_OWNER(z88_state, z88) MCFG_PALETTE_INIT_OWNER(z88_state, z88)
MCFG_DEFAULT_LAYOUT(layout_lcd) MCFG_DEFAULT_LAYOUT(layout_lcd)
MCFG_DEVICE_ADD(m_blink, UPD65031, XTAL(9'830'400)) device = &UPD65031(config, m_blink, XTAL(9'830'400));
MCFG_UPD65031_KB_CALLBACK(READ8(*this, z88_state, kb_r)) MCFG_UPD65031_KB_CALLBACK(READ8(*this, z88_state, kb_r))
MCFG_UPD65031_INT_CALLBACK(INPUTLINE(m_maincpu, INPUT_LINE_IRQ0)) MCFG_UPD65031_INT_CALLBACK(INPUTLINE(m_maincpu, INPUT_LINE_IRQ0))
MCFG_UPD65031_NMI_CALLBACK(INPUTLINE(m_maincpu, INPUT_LINE_NMI)) MCFG_UPD65031_NMI_CALLBACK(INPUTLINE(m_maincpu, INPUT_LINE_NMI))
@ -635,13 +635,15 @@ MACHINE_CONFIG_START(z88_state::z88)
MCFG_RAM_EXTRA_OPTIONS("32K,64K,256K,512k") MCFG_RAM_EXTRA_OPTIONS("32K,64K,256K,512k")
/* cartridges */ /* cartridges */
MCFG_DEVICE_ADD(m_carts[1], Z88CART_SLOT) device = &Z88CART_SLOT(config, m_carts[1]);
MCFG_DEVICE_SLOT_INTERFACE(z88_cart, nullptr, false) MCFG_DEVICE_SLOT_INTERFACE(z88_cart, nullptr, false)
MCFG_Z88CART_SLOT_OUT_FLP_CB(WRITELINE("blink", upd65031_device, flp_w)) MCFG_Z88CART_SLOT_OUT_FLP_CB(WRITELINE("blink", upd65031_device, flp_w))
MCFG_DEVICE_ADD(m_carts[2], Z88CART_SLOT)
device = &Z88CART_SLOT(config, m_carts[2]);
MCFG_DEVICE_SLOT_INTERFACE(z88_cart, nullptr, false) MCFG_DEVICE_SLOT_INTERFACE(z88_cart, nullptr, false)
MCFG_Z88CART_SLOT_OUT_FLP_CB(WRITELINE("blink", upd65031_device, flp_w)) MCFG_Z88CART_SLOT_OUT_FLP_CB(WRITELINE("blink", upd65031_device, flp_w))
MCFG_DEVICE_ADD(m_carts[3], Z88CART_SLOT)
device = &Z88CART_SLOT(config, m_carts[3]);
MCFG_DEVICE_SLOT_INTERFACE(z88_cart, nullptr, false) MCFG_DEVICE_SLOT_INTERFACE(z88_cart, nullptr, false)
MCFG_Z88CART_SLOT_OUT_FLP_CB(WRITELINE("blink", upd65031_device, flp_w)) MCFG_Z88CART_SLOT_OUT_FLP_CB(WRITELINE("blink", upd65031_device, flp_w))

View File

@ -14,27 +14,25 @@
inline void z88_state::plot_pixel(bitmap_ind16 &bitmap, int x, int y, uint16_t color) inline void z88_state::plot_pixel(bitmap_ind16 &bitmap, int x, int y, uint16_t color)
{ {
if (x<Z88_SCREEN_WIDTH) if (x < Z88_SCREEN_WIDTH)
bitmap.pix16(y, x) = color; bitmap.pix16(y, x) = color;
} }
// convert absolute offset into correct address to get data from // convert absolute offset into correct address to get data from
inline uint8_t* z88_state::convert_address(uint32_t offset) inline uint8_t* z88_state::convert_address(uint32_t offset)
{ {
uint8_t *ptr = nullptr;
if (offset < 0x080000) // rom if (offset < 0x080000) // rom
ptr = m_bios + (offset & 0x7ffff); return m_bios + (offset & 0x7ffff);
else if (offset < 0x100000) // slot0 else if (offset < 0x100000) // slot0
ptr = m_ram_base + (offset & 0x7ffff); return m_ram_base + (offset & 0x7ffff);
else if (offset < 0x200000) // slot1 else if (offset < 0x200000) // slot1
ptr = m_carts[1]->get_cart_base() + (offset & 0xfffff); return m_carts[1]->get_cart_base() + (offset & 0xfffff);
else if (offset < 0x300000) // slot2 else if (offset < 0x300000) // slot2
ptr = m_carts[2]->get_cart_base() + (offset & 0xfffff); return m_carts[2]->get_cart_base() + (offset & 0xfffff);
else if (offset < 0x400000) // slot3 else if (offset < 0x400000) // slot3
ptr = m_carts[3]->get_cart_base() + (offset & 0xfffff); return m_carts[3]->get_cart_base() + (offset & 0xfffff);
return ptr; return nullptr;
} }
/*************************************************************************** /***************************************************************************
@ -53,37 +51,36 @@ PALETTE_INIT_MEMBER(z88_state, z88)
void z88_state::vh_render_8x8(bitmap_ind16 &bitmap, int x, int y, uint16_t pen0, uint16_t pen1, uint8_t *gfx) void z88_state::vh_render_8x8(bitmap_ind16 &bitmap, int x, int y, uint16_t pen0, uint16_t pen1, uint8_t *gfx)
{ {
for (int h=0; h<8; h++) for (int h = 0; h < 8; h++)
{ {
uint8_t data = gfx[h]; uint8_t data = gfx[h];
for (int b=0; b<8; b++) for (int b = 0; b < 8; b++)
{ {
plot_pixel(bitmap, x+b, y+h, (data & 0x80) ? pen1 : pen0); plot_pixel(bitmap, x + b, y + h, BIT(data, 7 - b) ? pen1 : pen0);
data = data<<1;
} }
} }
} }
void z88_state::vh_render_6x8(bitmap_ind16 &bitmap, int x, int y, uint16_t pen0, uint16_t pen1, uint8_t *gfx) void z88_state::vh_render_6x8(bitmap_ind16 &bitmap, int x, int y, uint16_t pen0, uint16_t pen1, uint8_t *gfx)
{ {
for (int h=0; h<8; h++) for (int h = 0; h < 8; h++)
{ {
uint8_t data = gfx[h]<<2; uint8_t data = gfx[h] << 2;
for (int b=0; b<6; b++) for (int b = 0; b < 6; b++)
{ {
plot_pixel(bitmap, x+1+b, y+h, (data & 0x80) ? pen1 : pen0); plot_pixel(bitmap, x + 1 + b, y + h, BIT(data, 7 - b) ? pen1 : pen0);
data = data<<1;
} }
} }
} }
void z88_state::vh_render_line(bitmap_ind16 &bitmap, int x, int y, uint16_t pen) void z88_state::vh_render_line(bitmap_ind16 &bitmap, int x, int y, uint16_t pen)
{ {
for (int i=0; i<8; i++) for (int i = 0; i < 8; i++)
{
plot_pixel(bitmap, x + i, y + 7, pen); plot_pixel(bitmap, x + i, y + 7, pen);
}
} }
UPD65031_SCREEN_UPDATE(z88_state::lcd_update) UPD65031_SCREEN_UPDATE(z88_state::lcd_update)
@ -95,30 +92,24 @@ UPD65031_SCREEN_UPDATE(z88_state::lcd_update)
} }
else else
{ {
uint8_t *vram = convert_address(sbf<<11); uint8_t *vram = convert_address(sbf << 11);
for (int y=0; y<(Z88_SCREEN_HEIGHT>>3); y++) for (int y = 0; y < (Z88_SCREEN_HEIGHT >> 3); y++)
{ {
int x = 0, c = 0; int x = 0, c = 0;
while (x < Z88_SCREEN_WIDTH) while (x < Z88_SCREEN_WIDTH)
{ {
uint16_t pen0, pen1;
uint8_t *char_gfx;
uint8_t byte0 = vram[(y * 0x100) + c]; uint8_t byte0 = vram[(y * 0x100) + c];
uint8_t byte1 = vram[(y * 0x100) + c + 1]; uint8_t byte1 = vram[(y * 0x100) + c + 1];
// inverted graphics? // inverted graphics?
uint16_t pen0 = 0;
uint16_t pen1 = 0;
if (byte1 & Z88_SCR_HW_REV) if (byte1 & Z88_SCR_HW_REV)
{
pen0 = (byte1 & Z88_SCR_HW_GRY) ? 2 : 1; pen0 = (byte1 & Z88_SCR_HW_GRY) ? 2 : 1;
pen1 = 0;
}
else else
{
pen0 = 0;
pen1 = (byte1 & Z88_SCR_HW_GRY) ? 2 : 1; pen1 = (byte1 & Z88_SCR_HW_GRY) ? 2 : 1;
}
if ((byte1 & Z88_SCR_HW_NULL) == Z88_SCR_HW_NULL) if ((byte1 & Z88_SCR_HW_NULL) == Z88_SCR_HW_NULL)
{ {
@ -127,56 +118,42 @@ UPD65031_SCREEN_UPDATE(z88_state::lcd_update)
else if (!(byte1 & Z88_SCR_HW_HRS) || (((byte1 & Z88_SCR_HW_CURS) == Z88_SCR_HW_CURS))) else if (!(byte1 & Z88_SCR_HW_HRS) || (((byte1 & Z88_SCR_HW_CURS) == Z88_SCR_HW_CURS)))
{ {
// low-res 6x8 // low-res 6x8
uint16_t ch = (byte0 | (byte1<<8)) & 0x1ff; const uint16_t ch = (byte0 | (byte1 << 8)) & 0x1ff;
uint8_t *char_gfx;
if ((ch & 0x01c0) == 0x01c0) if ((ch & 0x01c0) == 0x01c0)
{ char_gfx = convert_address(lores0 << 9) + ((ch & 0x3f) << 3);
ch &= 0x3f;
char_gfx = convert_address(lores0<<9);
}
else else
{ char_gfx = convert_address(lores1 << 12) + (ch << 3);
char_gfx = convert_address(lores1<<12);
}
char_gfx += (ch<<3);
// cursor flash // cursor flash
if (flash && (byte1 & Z88_SCR_HW_CURS) == Z88_SCR_HW_CURS) if (flash && (byte1 & Z88_SCR_HW_CURS) == Z88_SCR_HW_CURS)
vh_render_6x8(bitmap, x,(y<<3), pen1, pen0, char_gfx); vh_render_6x8(bitmap, x, y << 3, pen1, pen0, char_gfx);
else else
vh_render_6x8(bitmap, x,(y<<3), pen0, pen1, char_gfx); vh_render_6x8(bitmap, x, y << 3, pen0, pen1, char_gfx);
// underline? // underline?
if (byte1 & Z88_SCR_HW_UND) if (byte1 & Z88_SCR_HW_UND)
vh_render_line(bitmap, x, (y<<3), pen1); vh_render_line(bitmap, x, y << 3, pen1);
x += 6; x += 6;
} }
else if ((byte1 & Z88_SCR_HW_HRS) && !(byte1 & Z88_SCR_HW_REV)) else if ((byte1 & Z88_SCR_HW_HRS) && !(byte1 & Z88_SCR_HW_REV))
{ {
// high-res 8x8 // high-res 8x8
uint16_t ch = (byte0 | (byte1<<8)) & 0x3ff; const uint16_t ch = (byte0 | (byte1 << 8)) & 0x3ff;
if (ch & 0x0100) uint8_t *char_gfx;
{ if (BIT(ch, 8))
ch &= 0xff; char_gfx = convert_address(hires1 << 11) + ((ch & 0xff) << 3);
char_gfx = convert_address(hires1<<11);
}
else else
{ char_gfx = convert_address(hires0 << 13) + ((ch & 0xff) << 3);
ch &= 0xff;
char_gfx = convert_address(hires0<<13);
}
char_gfx += (ch<<3);
// flash // flash
if ((byte1 & Z88_SCR_HW_FLS) && flash) if ((byte1 & Z88_SCR_HW_FLS) && flash)
pen0 = pen1 = 0; pen0 = pen1 = 0;
vh_render_8x8(bitmap, x,(y<<3), pen0, pen1, char_gfx); vh_render_8x8(bitmap, x, y << 3, pen0, pen1, char_gfx);
x += 8; x += 8;
} }