1 // license:BSD-3-Clause 2 // copyright-holders:Steve Ellenoff,Jarek Parchanski 3 #ifndef MAME_INCLUDES_GSWORD_H 4 #define MAME_INCLUDES_GSWORD_H 5 6 #pragma once 7 8 #include "machine/gen_latch.h" 9 #include "sound/ay8910.h" 10 #include "sound/msm5205.h" 11 #include "emupal.h" 12 #include "tilemap.h" 13 14 class gsword_state_base : public driver_device 15 { 16 public: gsword_state_base(const machine_config & mconfig,device_type type,const char * tag)17 gsword_state_base(const machine_config &mconfig, device_type type, const char *tag) 18 : driver_device(mconfig, type, tag) 19 , m_maincpu(*this, "maincpu") 20 , m_audiocpu(*this, "audiocpu") 21 , m_subcpu(*this, "sub") 22 , m_ay0(*this, "ay1") 23 , m_ay1(*this, "ay2") 24 , m_gfxdecode(*this, "gfxdecode") 25 , m_palette(*this, "palette") 26 , m_spritetile_ram(*this, "spritetile_ram") 27 , m_spritexy_ram(*this, "spritexy_ram") 28 , m_spriteattrib_ram(*this, "spriteattram") 29 , m_videoram(*this, "videoram") 30 , m_cpu2_ram(*this, "cpu2_ram") 31 { 32 } 33 34 protected: 35 required_device<cpu_device> m_maincpu; 36 required_device<cpu_device> m_audiocpu; 37 optional_device<cpu_device> m_subcpu; 38 required_device<ay8910_device> m_ay0; 39 required_device<ay8910_device> m_ay1; 40 required_device<gfxdecode_device> m_gfxdecode; 41 required_device<palette_device> m_palette; 42 43 required_shared_ptr<uint8_t> m_spritetile_ram; 44 required_shared_ptr<uint8_t> m_spritexy_ram; 45 required_shared_ptr<uint8_t> m_spriteattrib_ram; 46 required_shared_ptr<uint8_t> m_videoram; 47 required_shared_ptr<uint8_t> m_cpu2_ram; 48 49 int m_fake8910_0; 50 int m_fake8910_1; 51 int m_charbank; 52 int m_charpalbank; 53 int m_flipscreen; 54 tilemap_t *m_bg_tilemap; 55 56 // common 57 void videoram_w(offs_t offset, u8 data); 58 void charbank_w(u8 data); 59 void videoctrl_w(u8 data); 60 void scroll_w(u8 data); 61 void ay8910_control_port_0_w(u8 data); 62 void ay8910_control_port_1_w(u8 data); 63 u8 fake_0_r(); 64 u8 fake_1_r(); 65 66 TILE_GET_INFO_MEMBER(get_bg_tile_info); 67 68 virtual void machine_start() override; 69 virtual void machine_reset() override; 70 virtual void video_start() override; 71 72 uint32_t screen_update_gsword(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 73 void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); 74 void cpu1_map(address_map &map); 75 }; 76 77 78 class gsword_state : public gsword_state_base 79 { 80 public: gsword_state(const machine_config & mconfig,device_type type,const char * tag)81 gsword_state(const machine_config &mconfig, device_type type, const char *tag) 82 : gsword_state_base(mconfig, type, tag) 83 , m_soundlatch(*this, "soundlatch") 84 , m_msm(*this, "msm") 85 , m_dsw0(*this, "DSW0") 86 , m_protect_hack(false) 87 , m_nmi_enable(false) 88 , m_tclk_val(false) 89 , m_mcu1_p1(0xff) 90 , m_mcu2_p1(0xff) 91 { 92 } 93 94 void init_gsword(); 95 void init_gsword2(); 96 97 void gsword(machine_config &config); 98 99 protected: 100 u8 hack_r(offs_t offset); 101 void nmi_set_w(u8 data); 102 void sound_command_w(u8 data); 103 void adpcm_data_w(u8 data); 104 u8 mcu2_p1_r(); 105 void mcu3_p2_w(u8 data); 106 107 INTERRUPT_GEN_MEMBER(sound_interrupt); 108 109 void gsword_palette(palette_device &palette) const; 110 111 virtual void machine_start() override; 112 virtual void machine_reset() override; 113 114 void cpu1_io_map(address_map &map); 115 void cpu2_io_map(address_map &map); 116 void cpu2_map(address_map &map); 117 void cpu3_map(address_map &map); 118 119 private: 120 required_device<generic_latch_8_device> m_soundlatch; 121 required_device<msm5205_device> m_msm; 122 required_ioport m_dsw0; 123 124 bool m_protect_hack; 125 bool m_nmi_enable; 126 bool m_tclk_val; 127 uint8_t m_mcu1_p1, m_mcu2_p1; 128 }; 129 130 131 class josvolly_state : public gsword_state_base 132 { 133 public: josvolly_state(const machine_config & mconfig,device_type type,const char * tag)134 josvolly_state(const machine_config &mconfig, device_type type, const char *tag) 135 : gsword_state_base(mconfig, type, tag) 136 , m_cpu2_nmi_enable(false) 137 , m_mcu1_p1(0xffU) 138 , m_mcu1_p2(0xffU) 139 , m_mcu2_p1(0xffU) 140 { 141 } 142 143 void josvolly(machine_config &config); 144 145 protected: 146 u8 mcu1_p1_r(); 147 u8 mcu1_p2_r(); 148 u8 mcu2_p1_r(); 149 u8 mcu2_p2_r(); 150 151 void cpu2_nmi_enable_w(u8 data); 152 void cpu2_irq_clear_w(u8 data); 153 void mcu1_p1_w(u8 data); 154 void mcu1_p2_w(u8 data); 155 void mcu2_p1_w(u8 data); 156 void mcu2_p2_w(u8 data); 157 158 void josvolly_palette(palette_device &palette) const; 159 160 virtual void machine_start() override; 161 virtual void machine_reset() override; 162 163 void josvolly_cpu1_io_map(address_map &map); 164 void josvolly_cpu2_io_map(address_map &map); 165 void josvolly_cpu2_map(address_map &map); 166 167 private: 168 bool m_cpu2_nmi_enable; 169 u8 m_mcu1_p1; 170 u8 m_mcu1_p2; 171 u8 m_mcu2_p1; 172 }; 173 174 #endif // MAME_INCLUDES_GSWORD_H 175