1 // license:BSD-3-Clause 2 // copyright-holders:Jarek Parchanski, Nicola Salmoria, Mirko Buffoni 3 #ifndef MAME_INCLUDES_SYSTEM1_H 4 #define MAME_INCLUDES_SYSTEM1_H 5 6 #pragma once 7 8 #include "cpu/mcs51/mcs51.h" 9 #include "cpu/z80/z80.h" 10 #include "machine/z80pio.h" 11 #include "machine/gen_latch.h" 12 #include "machine/i8255.h" 13 #include "machine/segacrp2_device.h" 14 #include "machine/timer.h" 15 #include "emupal.h" 16 #include "screen.h" 17 #include "tilemap.h" 18 19 class system1_state : public driver_device 20 { 21 public: system1_state(const machine_config & mconfig,device_type type,const char * tag)22 system1_state(const machine_config &mconfig, device_type type, const char *tag) : 23 driver_device(mconfig, type, tag), 24 m_videoram(nullptr), 25 m_videomode_custom(nullptr), 26 m_maincpu(*this, "maincpu"), 27 m_soundcpu(*this, "soundcpu"), 28 m_mcu(*this, "mcu"), 29 m_gfxdecode(*this, "gfxdecode"), 30 m_screen(*this, "screen"), 31 m_palette(*this, "palette"), 32 m_soundlatch(*this, "soundlatch"), 33 m_ppi8255(*this, "ppi8255"), 34 m_pio(*this, "pio"), 35 m_ram(*this, "ram"), 36 m_spriteram(*this, "spriteram"), 37 m_paletteram(*this, "paletteram"), 38 m_decrypted_opcodes(*this, "decrypted_opcodes"), 39 m_maincpu_region(*this, "maincpu"), 40 m_spriterom(*this, "sprites"), 41 m_lookup_prom(*this, "lookup_proms"), 42 m_color_prom(*this, "color_proms"), 43 m_bank1(*this, "bank1"), 44 m_bank0d(*this, "bank0d"), 45 m_bank1d(*this, "bank1d"), 46 m_banked_decrypted_opcodes(nullptr) 47 { } 48 49 void sys1ppix_315_5051(machine_config &config); 50 void sys1ppisx_315_5064(machine_config &config); 51 void sys2_317_0007(machine_config &config); 52 void sys1piox_315_5110(machine_config &config); 53 void sys1piox_315_5065(machine_config &config); 54 void sys2m(machine_config &config); 55 void sys1ppix_315_5178(machine_config &config); 56 void sys1ppix_315_5179(machine_config &config); 57 void sys1piox_315_5093(machine_config &config); 58 void sys2_315_5176(machine_config &config); 59 void sys2(machine_config &config); 60 void sys2_315_5177(machine_config &config); 61 void nob(machine_config &config); 62 void blockgal(machine_config &config); 63 void sys1ppisx_315_5041(machine_config &config); 64 void sys1piox_315_5132(machine_config &config); 65 void sys1piox_315_5162(machine_config &config); 66 void sys1piox_315_5133(machine_config &config); 67 void sys1pioxb(machine_config &config); 68 void sys1ppi(machine_config &config); 69 void sys1piox_315_5135(machine_config &config); 70 void sys2rowxboot(machine_config &config); 71 void sys1piox_315_5102(machine_config &config); 72 void sys1piosx_315_spat(machine_config &config); 73 void sys2x(machine_config &config); 74 void sys1piox_315_5051(machine_config &config); 75 void sys1piox_315_5098(machine_config &config); 76 void sys1piosx_315_5099(machine_config &config); 77 void sys2xboot(machine_config &config); 78 void sys2xb(machine_config &config); 79 void nobm(machine_config &config); 80 void mcu(machine_config &config); 81 void sys2_317_0006(machine_config &config); 82 void sys1piox_317_0006(machine_config &config); 83 void sys1ppix_315_5033(machine_config &config); 84 void sys1pio(machine_config &config); 85 void sys1pios(machine_config &config); 86 void sys2rowm(machine_config &config); 87 void sys1ppix_315_5098(machine_config &config); 88 void sys1ppix_315_5048(machine_config &config); 89 void sys2row(machine_config &config); 90 void sys1ppis(machine_config &config); 91 void sys1ppix_315_5065(machine_config &config); 92 void sys1piox_315_5177(machine_config &config); 93 void sys1piox_315_5155(machine_config &config); 94 void sys2rowxb(machine_config &config); 95 96 void init_bank00(); 97 void init_bank0c(); 98 void init_bank44(); 99 100 void init_nobb(); 101 void init_dakkochn(); 102 void init_bootleg(); 103 void init_shtngmst(); 104 void init_blockgal(); 105 void init_nob(); 106 void init_myherok(); 107 void init_ufosensi(); 108 void init_wbml(); 109 void init_tokisens(); 110 void init_bootsys2(); 111 void init_bootsys2d(); 112 113 DECLARE_CUSTOM_INPUT_MEMBER(dakkochn_mux_data_r); 114 DECLARE_CUSTOM_INPUT_MEMBER(dakkochn_mux_status_r); 115 116 protected: 117 virtual void machine_start() override; 118 virtual void machine_reset() override; 119 virtual void video_start() override; 120 121 private: 122 // video related 123 std::unique_ptr<u8[]> m_videoram; 124 void (system1_state::*m_videomode_custom)(u8 data, u8 prevdata); 125 u8 m_videomode_prev; 126 std::unique_ptr<u8[]> m_mix_collide; 127 u8 m_mix_collide_summary; 128 std::unique_ptr<u8[]> m_sprite_collide; 129 u8 m_sprite_collide_summary; 130 bitmap_ind16 m_sprite_bitmap; 131 u8 m_video_mode; 132 u8 m_videoram_bank; 133 tilemap_t *m_tilemap_page[8]; 134 u8 m_tilemap_pages; 135 136 // protection, miscs 137 u8 m_mute_xor; 138 u8 m_dakkochn_mux_data; 139 u8 m_mcu_control; 140 u8 m_nob_maincpu_latch; 141 u8 m_nob_mcu_latch; 142 u8 m_nob_mcu_status; 143 int m_nobb_inport23_step; 144 145 // video handlers 146 void common_videomode_w(u8 data); 147 void videomode_w(u8 data); 148 void videoram_bank_w(u8 data); 149 u8 mixer_collision_r(offs_t offset); 150 void mixer_collision_w(offs_t offset, u8 data); 151 void mixer_collision_reset_w(u8 data); 152 u8 sprite_collision_r(offs_t offset); 153 void sprite_collision_w(offs_t offset, u8 data); 154 void sprite_collision_reset_w(u8 data); 155 u8 videoram_r(offs_t offset); 156 void videoram_w(offs_t offset, u8 data); 157 void paletteram_w(offs_t offset, u8 data); 158 159 // sound handlers 160 u8 sound_data_r(); 161 void soundport_w(u8 data); 162 void sound_control_w(u8 data); 163 164 // misc handlers 165 void mcu_control_w(u8 data); 166 u8 mcu_io_r(offs_t offset); 167 void mcu_io_w(offs_t offset, u8 data); 168 u8 nob_mcu_latch_r(); 169 void nob_mcu_latch_w(u8 data); 170 void nob_mcu_status_w(u8 data); 171 void nob_mcu_control_p2_w(u8 data); 172 u8 nob_maincpu_latch_r(); 173 void nob_maincpu_latch_w(u8 data); 174 u8 nob_mcu_status_r(); 175 u8 nobb_inport1c_r(); 176 u8 nobb_inport22_r(); 177 u8 nobb_inport23_r(); 178 void nobb_outport24_w(u8 data); 179 u8 nob_start_r(); 180 u8 shtngmst_gunx_r(); 181 182 // video functions 183 TILE_GET_INFO_MEMBER(tile_get_info); 184 void system1_palette(palette_device &palette) const; 185 DECLARE_MACHINE_START(system2); 186 DECLARE_VIDEO_START(system2); 187 DECLARE_MACHINE_START(myherok); 188 u32 screen_update_system1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 189 u32 screen_update_system2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 190 u32 screen_update_system2_rowscroll(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 191 void video_start_common(int pagecount); 192 inline void videoram_wait_states(cpu_device *cpu); 193 void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int xoffset); 194 void video_update_common(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind16 &fgpixmap, bitmap_ind16 **bgpixmaps, const int *bgrowscroll, int bgyscroll, int spritexoffs); 195 196 // misc functions 197 TIMER_DEVICE_CALLBACK_MEMBER(soundirq_gen); 198 TIMER_DEVICE_CALLBACK_MEMBER(mcu_t0_callback); 199 void bank44_custom_w(u8 data, u8 prevdata); 200 void bank0c_custom_w(u8 data, u8 prevdata); 201 void dakkochn_custom_w(u8 data, u8 prevdata); 202 203 // devices 204 required_device<z80_device> m_maincpu; 205 required_device<cpu_device> m_soundcpu; 206 optional_device<i8751_device> m_mcu; 207 required_device<gfxdecode_device> m_gfxdecode; 208 required_device<screen_device> m_screen; 209 required_device<palette_device> m_palette; 210 required_device<generic_latch_8_device> m_soundlatch; 211 optional_device<i8255_device> m_ppi8255; 212 optional_device<z80pio_device> m_pio; 213 214 // shared pointers 215 required_shared_ptr<u8> m_ram; 216 required_shared_ptr<u8> m_spriteram; 217 required_shared_ptr<u8> m_paletteram; 218 optional_shared_ptr<u8> m_decrypted_opcodes; 219 220 // memory regions 221 required_memory_region m_maincpu_region; 222 required_region_ptr<u8> m_spriterom; 223 required_region_ptr<u8> m_lookup_prom; 224 optional_region_ptr<u8> m_color_prom; 225 226 // banks 227 required_memory_bank m_bank1; 228 optional_memory_bank m_bank0d; 229 optional_memory_bank m_bank1d; 230 std::unique_ptr<u8[]> m_banked_decrypted_opcodes; 231 232 // address maps 233 void banked_decrypted_opcodes_map(address_map &map); 234 void decrypted_opcodes_map(address_map &map); 235 void encrypted_sys1ppi_maps(machine_config &config); 236 void encrypted_sys1pio_maps(machine_config &config); 237 void encrypted_sys2_mc8123_maps(machine_config &config); 238 void mcu_io_map(address_map &map); 239 void nobo_map(address_map &map); 240 void sound_map(address_map &map); 241 void system1_map(address_map &map); 242 void blockgal_pio_io_map(address_map &map); 243 void system1_pio_io_map(address_map &map); 244 void system1_ppi_io_map(address_map &map); 245 }; 246 247 #endif // MAME_INCLUDES_SYSTEM1_H 248