Skip to content

Commit

Permalink
hitachi: Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
cuavas committed Sep 26, 2024
1 parent ea48cc6 commit b86767a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 43 deletions.
14 changes: 13 additions & 1 deletion src/mame/hitachi/bml3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,21 @@ Basic Master Level 3 (MB-689x) "Peach" (c) 1980 Hitachi
**************************************************************************************************/

#include "emu.h"

#include "bml3.h"

#include "bus/bml3/kanji.h"
#include "bus/bml3/mp1802.h"
#include "bus/bml3/mp1805.h"
#include "bus/bml3/rtc.h"
#include "cpu/m6809/m6809.h"
#include "machine/6821pia.h"
#include "machine/clock.h"

#include "screen.h"
#include "softlist_dev.h"
#include "speaker.h"


MC6845_UPDATE_ROW( bml3_state::crtc_update_row )
{
rgb_t const *const palette = m_palette->palette()->entry_list_raw();
Expand Down
16 changes: 3 additions & 13 deletions src/mame/hitachi/bml3.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,15 @@
#pragma once

#include "bus/bml3/bml3bus.h"
#include "bus/bml3/kanji.h"
#include "bus/bml3/mp1802.h"
#include "bus/bml3/mp1805.h"
#include "bus/bml3/rtc.h"
#include "cpu/m6809/m6809.h"
#include "imagedev/cassette.h"
#include "machine/6821pia.h"
#include "machine/6850acia.h"
#include "machine/clock.h"
#include "machine/timer.h"
#include "sound/spkrdev.h"
#include "sound/ymopn.h"
#include "machine/timer.h"
#include "video/mc6845.h"

#include "emupal.h"
#include "screen.h"
#include "softlist_dev.h"
#include "speaker.h"

namespace {

// System clock definitions, from the MB-6890 servce manual, p.48:

Expand Down Expand Up @@ -61,7 +50,7 @@ namespace {
// / 6720 // 2400
// / 3360 // 4800
// / 1680 // 9600
} // anonymous namespace


class bml3_state : public driver_device
{
Expand Down Expand Up @@ -223,6 +212,7 @@ class bml3mk5_state : public bml3mk2_state
void ig_ram_w(offs_t offset, u8 data);

memory_view m_ig_view;

private:
required_device<gfxdecode_device> m_gfxdecode;
std::unique_ptr<u8[]> m_ig_ram;
Expand Down
28 changes: 14 additions & 14 deletions src/mame/hitachi/mbs1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ MB-S1 (c) 1984 Hitachi
#include "softlist_dev.h"
#include "speaker.h"


namespace {

class mbs1_state : public bml3mk5_state
{
public:
Expand All @@ -30,16 +33,17 @@ class mbs1_state : public bml3mk5_state
, m_system_mode(*this, "SYSTEM_MODE")
{ }

void mbs1(machine_config &config);
void mbs1(machine_config &config) ATTR_COLD;

protected:
virtual void machine_start() override ATTR_COLD;
virtual void machine_reset() override ATTR_COLD;

// virtual void main_map(address_map &map) override ATTR_COLD;
virtual void system_io(address_map &map) override ATTR_COLD;
void s1_map(address_map &map);
void s1_mmu_map(address_map &map);
void s1_ext_io(address_map &map);
void s1_map(address_map &map) ATTR_COLD;
void s1_mmu_map(address_map &map) ATTR_COLD;
void s1_ext_io(address_map &map) ATTR_COLD;

virtual MC6845_UPDATE_ROW(crtc_update_row) override;

Expand All @@ -64,7 +68,7 @@ MC6845_UPDATE_ROW( mbs1_state::crtc_update_row )
u8 const bgcolor = 0; //m_hres_reg & 7;

// TODO: WIDTH80, pinpoint bit used
for(u8 x=0; x<x_count; x+= 2)
for (u8 x = 0; x < x_count; x += 2)
{
u16 mem = ((ma + x) >> 1) & 0x7ff;

Expand All @@ -77,15 +81,10 @@ MC6845_UPDATE_ROW( mbs1_state::crtc_update_row )

u8 gfx_data = m_p_chargen[(tile<<4)|(ra<<1)|tile_bank];

for(u8 xi = 0; xi< 8; xi++)
for (u8 xi = 0; xi < 8; xi++)
{
u8 pen;
if(reverse)
pen = (gfx_data >> (7-xi) & 1) ? bgcolor : color;
else
pen = (gfx_data >> (7-xi) & 1) ? color : bgcolor;

const int res_x = x * 8 + xi * 2;
u8 const pen = BIT(reverse ? ~gfx_data : gfx_data, 7 - xi) ? color : bgcolor;
int const res_x = x * 8 + xi * 2;
bitmap.pix(y, res_x + 0) = palette[pen];
bitmap.pix(y, res_x + 1) = palette[pen];
}
Expand Down Expand Up @@ -341,6 +340,7 @@ ROM_START( mbs1 )
ROM_LOAD("font.rom", 0x0000, 0x1000, CRC(d1f27c5a) SHA1(a3abbdea9f6656bd795fd35ee806a54d7be35de0) )
ROM_END

} // anonymous namespace

COMP( 1984, mbs1, 0, 0, mbs1, mbs1, mbs1_state, empty_init, "Hitachi", "MB-S1", MACHINE_NOT_WORKING )

COMP( 1984, mbs1, 0, 0, mbs1, mbs1, mbs1_state, empty_init, "Hitachi", "MB-S1", MACHINE_NOT_WORKING )
19 changes: 13 additions & 6 deletions src/mame/hitachi/mbs1_mmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,20 @@ Hitachi MB-S1 MMU support
#include "emu.h"
#include "mbs1_mmu.h"

#include <algorithm>


DEFINE_DEVICE_TYPE(MBS1_MMU, mbs1_mmu_device, "mbs1_mmu", "Hitachi MB-S1 MMU")

mbs1_mmu_device::mbs1_mmu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, MBS1_MMU, tag, owner, clock)
, device_memory_interface(mconfig, *this)
, m_space_config("memory_map", ENDIANNESS_BIG, 8, 20, 0)
{
std::fill(std::begin(m_bank_latch), std::end(m_bank_latch), 0);
}

mbs1_mmu_device::~mbs1_mmu_device()
{
}

Expand All @@ -38,7 +46,7 @@ device_memory_interface::space_config_vector mbs1_mmu_device::memory_space_confi

void mbs1_mmu_device::device_start()
{
m_space = &space();
space().specific(m_space);

save_pointer(NAME(m_bank_latch), 16);
}
Expand All @@ -50,30 +58,29 @@ void mbs1_mmu_device::device_reset()
// TODO: should not reset everything when in user mode
void mbs1_mmu_device::init_banks(bool system_type, bool user_mode)
{
int i;
if (system_type == true)
{
for (i = 0; i < 14; i++)
for (int i = 0; i < 14; i++)
m_bank_latch[i] = 0xf0 | i;
m_bank_latch[0xe] = 0x84;
m_bank_latch[0xf] = 0xef;
}
else
{
// Level 3 mode
for (i = 0; i < 16; i++)
for (int i = 0; i < 16; i++)
m_bank_latch[i] = 0xf0 | i;
}
}

u8 mbs1_mmu_device::read(offs_t offset)
{
return m_space->read_byte((offset & 0xfff) | (m_bank_latch[offset >> 12] << 12));
return m_space.read_byte((offset & 0xfff) | (m_bank_latch[offset >> 12] << 12));
}

void mbs1_mmu_device::write(offs_t offset, u8 data)
{
m_space->write_byte((offset & 0xfff) | (m_bank_latch[offset >> 12] << 12), data);
m_space.write_byte((offset & 0xfff) | (m_bank_latch[offset >> 12] << 12), data);
}

u8 mbs1_mmu_device::bank_r(offs_t offset)
Expand Down
19 changes: 10 additions & 9 deletions src/mame/hitachi/mbs1_mmu.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// license: BSD-3-Clause
// copyright-holders: Angelo Salese

#ifndef MAME_MBS1_MMU_H
#define MAME_MBS1_MMU_H
#ifndef MAME_HITACHI_MBS1_MMU_H
#define MAME_HITACHI_MBS1_MMU_H

#pragma once


class mbs1_mmu_device : public device_t, public device_memory_interface
{
public:
mbs1_mmu_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0);
virtual ~mbs1_mmu_device();

// configuration helpers
template <typename... T> mbs1_mmu_device& set_map(T &&... args) { set_addrmap(0, std::forward<T>(args)...); return *this; }
Expand All @@ -23,18 +24,18 @@ class mbs1_mmu_device : public device_t, public device_memory_interface
void init_banks(bool system_type, bool user_mode);

protected:
virtual space_config_vector memory_space_config() const override;
virtual space_config_vector memory_space_config() const override ATTR_COLD;

virtual void device_start() override ATTR_COLD;
virtual void device_reset() override ATTR_COLD;

virtual void device_start() override;
virtual void device_reset() override;
private:
const address_space_config m_space_config;
address_space *m_space;
memory_access<20, 0, 0, ENDIANNESS_BIG>::specific m_space;

u8 m_bank_latch[16]{};
u8 m_bank_latch[16];
};

DECLARE_DEVICE_TYPE(MBS1_MMU, mbs1_mmu_device)


#endif // MAME_MBS1_MMU_H

0 comments on commit b86767a

Please sign in to comment.