diff options
Diffstat (limited to 'src/mame/drivers/tugboat.cpp')
-rw-r--r-- | src/mame/drivers/tugboat.cpp | 73 |
1 files changed, 34 insertions, 39 deletions
diff --git a/src/mame/drivers/tugboat.cpp b/src/mame/drivers/tugboat.cpp index e5231a3e925..55e3d72b31c 100644 --- a/src/mame/drivers/tugboat.cpp +++ b/src/mame/drivers/tugboat.cpp @@ -37,22 +37,30 @@ always false - counter was reloaded and incremented before interrupt occurs class tugboat_state : public driver_device { public: - tugboat_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), + tugboat_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_gfxdecode(*this, "gfxdecode"), m_screen(*this, "screen"), m_palette(*this, "palette"), - m_ram(*this, "ram") { } + m_ram(*this, "ram") + { } void tugboat(machine_config &config); -private: +protected: enum { TIMER_INTERRUPT }; + virtual void machine_start() override; + virtual void video_start() override; + virtual void machine_reset() override; + + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + +private: required_device<cpu_device> m_maincpu; required_device<gfxdecode_device> m_gfxdecode; required_device<screen_device> m_screen; @@ -73,17 +81,12 @@ private: DECLARE_READ8_MEMBER(input_r); DECLARE_WRITE8_MEMBER(ctrl_w); - virtual void machine_start() override; - virtual void video_start() override; - virtual void machine_reset() override; - DECLARE_PALETTE_INIT(tugboat); + void tugboat_palette(palette_device &palette) const; uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void draw_tilemap(bitmap_ind16 &bitmap, const rectangle &cliprect, int addr, int gfx0, int gfx1, int transparency); void main_map(address_map &map); - - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; }; @@ -104,24 +107,19 @@ void tugboat_state::video_start() m_gfxdecode->gfx(2)->set_granularity(8); } -/* there isn't the usual resistor array anywhere near the color prom, - just four 1k resistors. */ -PALETTE_INIT_MEMBER(tugboat_state, tugboat) +// there isn't the usual resistor array anywhere near the color PROM, just four 1k resistors. +void tugboat_state::tugboat_palette(palette_device &palette) const { - const uint8_t *color_prom = memregion("proms")->base(); - int i; - - for (i = 0;i < palette.entries();i++) + uint8_t const *const color_prom = memregion("proms")->base(); + for (int i = 0; i < palette.entries(); i++) { - int r,g,b,brt; + int const brt = BIT(color_prom[i], 3) ? 0xff : 0x80; - brt = ((color_prom[i] >> 3) & 0x01) ? 0xff : 0x80; + int const r = brt * BIT(color_prom[i], 0); + int const g = brt * BIT(color_prom[i], 1); + int const b = brt * BIT(color_prom[i], 2); - r = brt * ((color_prom[i] >> 0) & 0x01); - g = brt * ((color_prom[i] >> 1) & 0x01); - b = brt * ((color_prom[i] >> 2) & 0x01); - - palette.set_pen_color(i,rgb_t(r,g,b)); + palette.set_pen_color(i, rgb_t(r, g, b)); } } @@ -147,20 +145,18 @@ WRITE8_MEMBER(tugboat_state::score_w) if (offset<0x8 ) m_ram[0x291d + 32*offset + 32*9] = data ^ 0x0f; } -void tugboat_state::draw_tilemap(bitmap_ind16 &bitmap,const rectangle &cliprect, - int addr,int gfx0,int gfx1,int transparency) +void tugboat_state::draw_tilemap(bitmap_ind16 &bitmap, const rectangle &cliprect, + int addr, int gfx0, int gfx1, int transparency) { - int x,y; - - for (y = 0;y < 32;y++) + for (int y = 0; y < 32; y++) { - for (x = 0;x < 32;x++) + for (int x = 0; x < 32; x++) { int attr = m_ram[addr + 0x400]; int code = ((attr & 0x01) << 8) | m_ram[addr]; int color = (attr & 0x3c) >> 2; - int rgn, transpen; + int rgn, transpen; if (attr & 0x02) { rgn = gfx1; @@ -186,12 +182,12 @@ void tugboat_state::draw_tilemap(bitmap_ind16 &bitmap,const rectangle &cliprect, uint32_t tugboat_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - int startaddr0 = m_hd46505_0_reg[0x0c]*256 + m_hd46505_0_reg[0x0d]; - int startaddr1 = m_hd46505_1_reg[0x0c]*256 + m_hd46505_1_reg[0x0d]; + int const startaddr0 = m_hd46505_0_reg[0x0c]*256 + m_hd46505_0_reg[0x0d]; + int const startaddr1 = m_hd46505_1_reg[0x0c]*256 + m_hd46505_1_reg[0x0d]; + draw_tilemap(bitmap, cliprect, startaddr0, 0, 1, false); + draw_tilemap(bitmap, cliprect, startaddr1, 2, 3, true); - draw_tilemap(bitmap,cliprect,startaddr0,0,1,false); - draw_tilemap(bitmap,cliprect,startaddr1,2,3,true); return 0; } @@ -379,12 +375,11 @@ MACHINE_CONFIG_START(tugboat_state::tugboat) MCFG_SCREEN_SIZE(32*8,32*8) MCFG_SCREEN_VISIBLE_AREA(1*8,31*8-1,2*8,30*8-1) MCFG_SCREEN_UPDATE_DRIVER(tugboat_state, screen_update) - MCFG_SCREEN_PALETTE("palette") + MCFG_SCREEN_PALETTE(m_palette) MCFG_SCREEN_VBLANK_CALLBACK(INPUTLINE("maincpu", INPUT_LINE_NMI)) - MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_tugboat) - MCFG_PALETTE_ADD("palette", 256) - MCFG_PALETTE_INIT_OWNER(tugboat_state, tugboat) + GFXDECODE(config, m_gfxdecode, m_palette, gfx_tugboat); + PALETTE(config, m_palette, FUNC(tugboat_state::tugboat_palette), 256); /* sound hardware */ SPEAKER(config, "mono").front_center(); |