trunk/src/emu/bus/msx_cart/dooly.c
| r0 | r30835 | |
| 1 | #include "emu.h" |
| 2 | #include "dooly.h" |
| 3 | |
| 4 | |
| 5 | const device_type MSX_CART_DOOLY = &device_creator<msx_cart_dooly>; |
| 6 | |
| 7 | |
| 8 | msx_cart_dooly::msx_cart_dooly(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 9 | : device_t(mconfig, MSX_CART_DOOLY, "MSX Cartridge - Dooly", tag, owner, clock, "msx_cart_dooly", __FILE__) |
| 10 | , msx_cart_interface(mconfig, *this) |
| 11 | , m_prot(0) |
| 12 | { |
| 13 | } |
| 14 | |
| 15 | |
| 16 | void msx_cart_dooly::device_start() |
| 17 | { |
| 18 | save_item(NAME(m_prot)); |
| 19 | } |
| 20 | |
| 21 | |
| 22 | void msx_cart_dooly::device_reset() |
| 23 | { |
| 24 | m_prot = 0; |
| 25 | } |
| 26 | |
| 27 | |
| 28 | void msx_cart_dooly::initialize_cartridge() |
| 29 | { |
| 30 | if (get_rom_size() != 0x8000) |
| 31 | { |
| 32 | fatalerror("dooly: Invalid ROM size\n"); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | |
| 37 | READ8_MEMBER(msx_cart_dooly::read_cart) |
| 38 | { |
| 39 | if (offset >= 0x4000 && offset < 0xc000) |
| 40 | { |
| 41 | UINT8 data = get_rom_base()[offset - 0x4000]; |
| 42 | |
| 43 | switch (m_prot) |
| 44 | { |
| 45 | case 0x04: |
| 46 | data = BITSWAP8(data, 7, 6, 5, 4, 3, 1, 0, 2); |
| 47 | break; |
| 48 | } |
| 49 | return data; |
| 50 | } |
| 51 | return 0xff; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | WRITE8_MEMBER(msx_cart_dooly::write_cart) |
| 56 | { |
| 57 | if (offset >= 0x4000 && offset < 0xc000) |
| 58 | { |
| 59 | m_prot = data & 0x07; |
| 60 | if (m_prot != 0 && m_prot != 4) |
| 61 | { |
| 62 | logerror("msx_cart_dooly: unhandled write %02x to %04x\n", data, offset); |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
trunk/src/emu/bus/msx_cart/dooly.h
| r0 | r30835 | |
| 1 | #ifndef __MSX_CART_DOOLY_H |
| 2 | #define __MSX_CART_DOOLY_H |
| 3 | |
| 4 | #include "bus/msx_cart/cartridge.h" |
| 5 | |
| 6 | |
| 7 | extern const device_type MSX_CART_DOOLY; |
| 8 | |
| 9 | |
| 10 | class msx_cart_dooly : public device_t |
| 11 | , public msx_cart_interface |
| 12 | { |
| 13 | public: |
| 14 | msx_cart_dooly(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 15 | |
| 16 | // device-level overrides |
| 17 | virtual void device_start(); |
| 18 | virtual void device_reset(); |
| 19 | |
| 20 | virtual void initialize_cartridge(); |
| 21 | |
| 22 | virtual DECLARE_READ8_MEMBER(read_cart); |
| 23 | virtual DECLARE_WRITE8_MEMBER(write_cart); |
| 24 | |
| 25 | private: |
| 26 | UINT8 m_prot; |
| 27 | }; |
| 28 | |
| 29 | |
| 30 | #endif |