hotblock.cpp : Minor cleanups

PALETTE_FORMAT for palette, Add notes, Cleanup video update routine, Convert VRAM array into std::unique_ptr, confirmed XTAL (PCB is only has 24 MHz XTAL)
This commit is contained in:
cam900 2018-10-31 01:47:56 +09:00
parent 04990578bd
commit 9315d0dff5

View File

@ -40,6 +40,7 @@ so it could be by them instead
#include "emu.h"
#include "cpu/i86/i86.h"
//#include "machine/i2cmem.h"
#include "sound/ay8910.h"
#include "emupal.h"
#include "screen.h"
@ -49,11 +50,12 @@ so it could be by them instead
class hotblock_state : public driver_device
{
public:
hotblock_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
hotblock_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_palette(*this, "palette"),
m_vram(*this, "vram") { }
m_palette(*this, "palette")/*,
m_i2cmem(*this, "i2cmem")*/
{ }
void hotblock(machine_config &config);
@ -61,16 +63,14 @@ private:
/* devices */
required_device<cpu_device> m_maincpu;
required_device<palette_device> m_palette;
/* memory pointers */
required_shared_ptr<uint8_t> m_vram;
// required_device<i2cmem_device> m_i2cmem;
/* misc */
int m_port0;
int m_port4;
/* memory */
uint8_t m_pal[0x10000];
std::unique_ptr<uint8_t[]> m_vram;
DECLARE_READ8_MEMBER(video_read);
DECLARE_READ8_MEMBER(port4_r);
@ -86,13 +86,15 @@ private:
};
READ8_MEMBER(hotblock_state::video_read)
{
/* right?, anything else?? */
if (m_port0 & 0x20) // port 0 = a8 e8 -- palette
{
return m_pal[offset];
if (offset < 0x200)
return m_palette->read8(space, offset);
return 0;
}
else // port 0 = 88 c8
{
@ -104,17 +106,19 @@ READ8_MEMBER(hotblock_state::video_read)
READ8_MEMBER(hotblock_state::port4_r)
{
// osd_printf_debug("port4_r\n");
//logerror("trying to read port 4 at maincpu pc %08x\n", m_maincpu->pc());
//return (m_i2cmem->read_sda() & 1);
return 0x00;
}
WRITE8_MEMBER(hotblock_state::port4_w)
{
//logerror("trying to write port 4 in %02x at maincpu pc %08x\n", data, m_maincpu->pc());
m_port4 = data;
}
WRITE8_MEMBER(hotblock_state::port0_w)
{
m_port0 = data;
@ -125,7 +129,8 @@ WRITE8_MEMBER(hotblock_state::video_write)
/* right?, anything else?? */
if (m_port0 & 0x20) // port 0 = a8 e8 -- palette
{
m_pal[offset] = data;
if (offset < 0x200)
m_palette->write8(space, offset, data);
}
else // port 0 = 88 c8
{
@ -136,7 +141,7 @@ WRITE8_MEMBER(hotblock_state::video_write)
void hotblock_state::hotblock_map(address_map &map)
{
map(0x00000, 0x0ffff).ram();
map(0x10000, 0x1ffff).rw(FUNC(hotblock_state::video_read), FUNC(hotblock_state::video_write)).share("vram");
map(0x10000, 0x1ffff).rw(FUNC(hotblock_state::video_read), FUNC(hotblock_state::video_write)).share("palette");
map(0x20000, 0xfffff).rom();
}
@ -152,33 +157,26 @@ void hotblock_state::hotblock_io(address_map &map)
void hotblock_state::video_start()
{
save_item(NAME(m_pal));
m_vram = make_unique_clear<uint8_t[]>(0x10000);
save_pointer(NAME(m_vram), 0x10000);
save_item(NAME(m_port0));
save_item(NAME(m_port4)); //stored but not read for now
}
uint32_t hotblock_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
int y, x, count;
int i;
static const int xxx = 320, yyy = 204;
bitmap.fill(m_palette->black_pen());
for (i = 0; i < 256; i++)
if (~m_port0 & 0x40)
{
int dat = (m_pal[i * 2 + 1] << 8) | m_pal[i * 2];
m_palette->set_pen_color(i, pal5bit(dat >> 0), pal5bit(dat >> 5), pal5bit(dat >> 10));
bitmap.fill(m_palette->black_pen(), cliprect);
return 0;
}
count = 0;
for (y = 0; y < yyy; y++)
for (int y = cliprect.top(); y <= cliprect.bottom(); y++)
{
for(x = 0; x < xxx; x++)
int count = (y * 320) + cliprect.left();
for(int x = cliprect.left(); x <= cliprect.right(); x++)
{
if (m_port0 & 0x40)
bitmap.pix16(y, x) = m_vram[count];
count++;
bitmap.pix16(y, x) = m_vram[count++];
}
}
@ -212,24 +210,25 @@ INPUT_PORTS_END
MACHINE_CONFIG_START(hotblock_state::hotblock)
/* basic machine hardware */
MCFG_DEVICE_ADD("maincpu", I8088, 10000000)
MCFG_DEVICE_ADD("maincpu", I8088, 24_MHz_XTAL / 3) // Unknown clock
MCFG_DEVICE_PROGRAM_MAP(hotblock_map)
MCFG_DEVICE_IO_MAP(hotblock_io)
// I2CMEM(config, m_i2cmem, 0).set_page_size(16).set_data_size(0x200); // 24C04
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_RAW_PARAMS(8000000, 512, 0, 320, 312, 0, 200) // 15.625 kHz horizontal???
MCFG_SCREEN_RAW_PARAMS(24_MHz_XTAL / 3, 512, 0, 320, 312, 0, 200) // 15.625 kHz horizontal???
MCFG_SCREEN_UPDATE_DRIVER(hotblock_state, screen_update)
MCFG_SCREEN_PALETTE("palette")
MCFG_SCREEN_VBLANK_CALLBACK(INPUTLINE("maincpu", INPUT_LINE_NMI)) // right?
MCFG_PALETTE_ADD("palette", 256)
PALETTE(config, m_palette, 0x200/2).set_format(PALETTE_FORMAT_xBBBBBGGGGGRRRRR);
/* sound hardware */
SPEAKER(config, "mono").front_center();
MCFG_DEVICE_ADD("aysnd", YM2149, 1000000)
MCFG_DEVICE_ADD("aysnd", YM2149, 24_MHz_XTAL / 24)
MCFG_AY8910_PORT_A_READ_CB(IOPORT("P1"))
MCFG_AY8910_PORT_B_READ_CB(IOPORT("P2"))
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)