summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/6883sam.h
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2020-04-18 21:58:36 -0400
committer AJR <ajrhacker@users.noreply.github.com>2020-04-18 21:58:39 -0400
commit146873a90450204857779ef76d3f51e450738936 (patch)
treefb7b695abe1fc1c68828ae84c6e074b90c627972 /src/mame/machine/6883sam.h
parent48177fe08cc6dd1c7d843544a273ec020d1bb684 (diff)
6883sam: Replace custom dynamic memory banking with conventional address spaces
Diffstat (limited to 'src/mame/machine/6883sam.h')
-rw-r--r--src/mame/machine/6883sam.h99
1 files changed, 30 insertions, 69 deletions
diff --git a/src/mame/machine/6883sam.h b/src/mame/machine/6883sam.h
index d1c48e5af12..f21140151f7 100644
--- a/src/mame/machine/6883sam.h
+++ b/src/mame/machine/6883sam.h
@@ -78,7 +78,7 @@ protected:
void update_cpu_clock();
};
-class sam6883_device : public device_t, public sam6883_friend_device_interface
+class sam6883_device : public device_t, public device_memory_interface, public sam6883_friend_device_interface
{
public:
template <typename T>
@@ -90,14 +90,12 @@ public:
sam6883_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- auto res_rd_callback() { return m_read_res.bind(); }
-
- // called to configure banks
- void configure_bank(int bank, uint8_t *memory, uint32_t memory_size, bool is_read_only);
- void configure_bank(int bank, read8_delegate rhandler, write8_delegate whandler);
+ // CPU read/write handlers
+ uint8_t read(offs_t offset);
+ void write(offs_t offset, uint8_t data);
// typically called by VDG
- ATTR_FORCE_INLINE DECLARE_READ8_MEMBER( display_read )
+ ATTR_FORCE_INLINE uint8_t display_read(offs_t offset)
{
if (offset == (offs_t) ~0)
{
@@ -116,82 +114,46 @@ public:
if (bit3_carry)
counter_carry_bit3();
}
- return m_read_res(m_counter & m_counter_mask);
+ return m_ram_space->read_byte(m_counter & m_counter_mask);
}
DECLARE_WRITE_LINE_MEMBER( hs_w );
- // typically called by machine
- address_space *mpu_address_space() const { return m_cpu_space; }
- void set_bank_offset(int bank, offs_t offset);
-
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_post_load() override;
-private:
- // represents an external memory bank - memory or IO that the SAM
- // points to with the S2/S1/S0 output
- struct sam_bank
- {
- sam_bank(device_t &owner) : m_rhandler(owner), m_whandler(owner) { }
-
- uint8_t * m_memory;
- uint32_t m_memory_size;
- offs_t m_memory_offset;
- bool m_memory_read_only;
- read8_delegate m_rhandler;
- write8_delegate m_whandler;
- };
-
- // represents one of the memory "spaces" (e.g. - $8000-$9FFF) that
- // can ultimately point to a bank
- template <uint16_t _addrstart, uint16_t _addrend>
- class sam_space
- {
- public:
- sam_space(sam6883_device &owner);
- void point(const sam_bank &bank, uint16_t offset, uint32_t length = ~0);
-
- private:
- sam6883_device & m_owner;
- memory_bank * m_read_bank;
- memory_bank * m_write_bank;
- uint32_t m_length;
-
- address_space &cpu_space() const;
- void point_specific_bank(const sam_bank &bank, uint32_t offset, uint32_t mask, memory_bank *&memory_bank, uint32_t addrstart, uint32_t addrend, bool is_write);
- };
+ // device_memory_interface overrides
+ virtual space_config_vector memory_space_config() const override;
- // incidentals
- address_space * m_cpu_space;
- devcb_read8 m_read_res;
- sam_bank m_banks[8];
- sam_space<0x0000, 0x7FFF> m_space_0000;
- sam_space<0x8000, 0x9FFF> m_space_8000;
- sam_space<0xA000, 0xBFFF> m_space_A000;
- sam_space<0xC000, 0xFEFF> m_space_C000;
- sam_space<0xFF00, 0xFF1F> m_space_FF00;
- sam_space<0xFF20, 0xFF3F> m_space_FF20;
- sam_space<0xFF40, 0xFF5F> m_space_FF40;
- sam_space<0xFF60, 0xFFBF> m_space_FF60;
- sam_space<0xFFE0, 0xFFF1> m_space_FFE0;
- sam_space<0xFFF2, 0xFFFF> m_space_FFF2;
- uint16_t m_counter_mask;
+private:
+ // memory space configuratino
+ address_space_config m_ram_config;
+ address_space_config m_rom0_config;
+ address_space_config m_rom1_config;
+ address_space_config m_rom2_config;
+ address_space_config m_io0_config;
+ address_space_config m_io1_config;
+ address_space_config m_io2_config;
+ address_space_config m_boot_config;
+
+ // memory spaces
+ using memory_cache_8be = memory_access_cache<0, 0, ENDIANNESS_BIG>;
+ memory_cache_8be * m_ram_space;
+ memory_cache_8be * m_rom_space[3];
+ address_space * m_io_space[3];
+ memory_cache_8be * m_boot_space;
+ uint16_t m_counter_mask;
// SAM state
- uint16_t m_counter;
- uint8_t m_counter_xdiv;
- uint8_t m_counter_ydiv;
-
- // dummy scratch memory
- uint8_t m_dummy[0x8000];
+ uint16_t m_counter;
+ uint8_t m_counter_xdiv;
+ uint8_t m_counter_ydiv;
// typically called by CPU
- DECLARE_READ8_MEMBER( read );
- DECLARE_WRITE8_MEMBER( write );
+ void internal_write(offs_t offset, uint8_t data);
// called when there is a carry out of bit 3 on the counter
ATTR_FORCE_INLINE void counter_carry_bit3()
@@ -248,7 +210,6 @@ private:
}
// other members
- void configure_bank(int bank, uint8_t *memory, uint32_t memory_size, bool is_read_only, read8_delegate rhandler, write8_delegate whandler);
void horizontal_sync();
void update_state();
void update_memory();