trunk/src/emu/bus/gameboy/mbc.h
| r31922 | r31923 | |
| 35 | 35 | { |
| 36 | 36 | public: |
| 37 | 37 | // construction/destruction |
| 38 | gb_rom_mbc1_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); |
| 38 | 39 | gb_rom_mbc1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 39 | 40 | |
| 40 | 41 | // device-level overrides |
| r31922 | r31923 | |
| 176 | 177 | UINT8 m_bank_mask, m_bank, m_reg; |
| 177 | 178 | }; |
| 178 | 179 | |
| 180 | // ======================> gb_rom_188in1_device |
| 181 | class gb_rom_188in1_device : public gb_rom_mbc1_device |
| 182 | { |
| 183 | public: |
| 184 | // construction/destruction |
| 185 | gb_rom_188in1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 186 | |
| 187 | // device-level overrides |
| 188 | virtual void device_start() { shared_start(); save_item(NAME(m_game_base)); }; |
| 189 | virtual void device_reset() { shared_reset(); m_game_base = 0; }; |
| 190 | |
| 191 | // reading and writing |
| 192 | virtual DECLARE_READ8_MEMBER(read_rom); |
| 193 | virtual DECLARE_WRITE8_MEMBER(write_bank); |
| 194 | |
| 195 | private: |
| 196 | UINT32 m_game_base; |
| 197 | }; |
| 198 | |
| 179 | 199 | // ======================> gb_rom_sintax_device |
| 180 | 200 | class gb_rom_sintax_device : public gb_rom_mbc_device |
| 181 | 201 | { |
| r31922 | r31923 | |
| 293 | 313 | extern const device_type GB_ROM_MBC6; |
| 294 | 314 | extern const device_type GB_ROM_MBC7; |
| 295 | 315 | extern const device_type GB_ROM_MMM01; |
| 316 | extern const device_type GB_ROM_188IN1; |
| 296 | 317 | extern const device_type GB_ROM_SINTAX; |
| 297 | 318 | extern const device_type GB_ROM_CHONGWU; |
| 298 | 319 | extern const device_type GB_ROM_LICHENG; |
trunk/src/emu/bus/gameboy/mbc.c
| r31922 | r31923 | |
| 24 | 24 | const device_type GB_ROM_MBC6 = &device_creator<gb_rom_mbc6_device>; |
| 25 | 25 | const device_type GB_ROM_MBC7 = &device_creator<gb_rom_mbc7_device>; |
| 26 | 26 | const device_type GB_ROM_MMM01 = &device_creator<gb_rom_mmm01_device>; |
| 27 | const device_type GB_ROM_188IN1 = &device_creator<gb_rom_188in1_device>; |
| 27 | 28 | const device_type GB_ROM_SINTAX = &device_creator<gb_rom_sintax_device>; |
| 28 | 29 | const device_type GB_ROM_CHONGWU = &device_creator<gb_rom_chongwu_device>; |
| 29 | 30 | const device_type GB_ROM_LICHENG = &device_creator<gb_rom_licheng_device>; |
| r31922 | r31923 | |
| 38 | 39 | { |
| 39 | 40 | } |
| 40 | 41 | |
| 42 | gb_rom_mbc1_device::gb_rom_mbc1_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) |
| 43 | : gb_rom_mbc_device(mconfig, type, name, tag, owner, clock, shortname, source) |
| 44 | { |
| 45 | } |
| 46 | |
| 41 | 47 | gb_rom_mbc1_device::gb_rom_mbc1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 42 | 48 | : gb_rom_mbc_device(mconfig, GB_ROM_MBC1, "GB MBC1 Carts", tag, owner, clock, "gb_rom_mbc1", __FILE__) |
| 43 | 49 | { |
| r31922 | r31923 | |
| 83 | 89 | { |
| 84 | 90 | } |
| 85 | 91 | |
| 92 | gb_rom_188in1_device::gb_rom_188in1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 93 | : gb_rom_mbc1_device(mconfig, GB_ROM_188IN1, "GB 188in1", tag, owner, clock, "gb_rom_188in1", __FILE__) |
| 94 | { |
| 95 | } |
| 96 | |
| 86 | 97 | gb_rom_sintax_device::gb_rom_sintax_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 87 | 98 | : gb_rom_mbc_device(mconfig, GB_ROM_SINTAX, "GB MBC5 Sintax Carts", tag, owner, clock, "gb_rom_sintax", __FILE__) |
| 88 | 99 | { |
| r31922 | r31923 | |
| 262 | 273 | |
| 263 | 274 | // MBC1 |
| 264 | 275 | |
| 265 | | |
| 266 | 276 | READ8_MEMBER(gb_rom_mbc1_device::read_rom) |
| 267 | 277 | { |
| 268 | 278 | if (offset < 0x4000) |
| r31922 | r31923 | |
| 689 | 699 | } |
| 690 | 700 | } |
| 691 | 701 | |
| 702 | // 188 in 1 pirate (only preliminary) |
| 703 | |
| 704 | READ8_MEMBER(gb_rom_188in1_device::read_rom) |
| 705 | { |
| 706 | if (offset < 0x4000) |
| 707 | return m_rom[m_game_base + rom_bank_map[m_latch_bank] * 0x4000 + (offset & 0x3fff)]; |
| 708 | else |
| 709 | return m_rom[m_game_base + rom_bank_map[m_latch_bank2] * 0x4000 + (offset & 0x3fff)]; |
| 710 | } |
| 711 | |
| 712 | WRITE8_MEMBER(gb_rom_188in1_device::write_bank) |
| 713 | { |
| 714 | if (offset == 0x7b00) |
| 715 | { |
| 716 | if (data < 0x80) |
| 717 | logerror("write to 0x%X data 0x%X\n", offset, data); |
| 718 | else |
| 719 | { |
| 720 | data -= 0x80; |
| 721 | m_game_base = 0x400000 + (data * 0x8000); |
| 722 | //logerror("offset 0x%X\n", m_game_base); |
| 723 | } |
| 724 | } |
| 725 | else if (offset == 0x7b01 || offset == 0x7b02) |
| 726 | { |
| 727 | // what do these writes do? |
| 728 | printf("write to 0x%X data 0x%X\n", offset, data); |
| 729 | } |
| 730 | else |
| 731 | gb_rom_mbc1_device::write_bank(space, offset, data); |
| 732 | } |
| 733 | |
| 734 | |
| 692 | 735 | // MBC5 variant used by Li Cheng / Niutoude games |
| 693 | 736 | |
| 694 | 737 | WRITE8_MEMBER(gb_rom_licheng_device::write_bank) |