1 // license:BSD-3-Clause 2 // copyright-holders:Aaron Giles 3 /*************************************************************************** 4 5 Sega System 16A/16B/18/Outrun/Hang On/X-Board/Y-Board hardware 6 7 ***************************************************************************/ 8 #ifndef MAME_INCLUDES_SEGAS18_H 9 #define MAME_INCLUDES_SEGAS18_H 10 11 #pragma once 12 13 #include "cpu/m68000/m68000.h" 14 #include "cpu/mcs51/mcs51.h" 15 #include "cpu/z80/z80.h" 16 #include "machine/315_5195.h" 17 #include "machine/315_5296.h" 18 #include "machine/nvram.h" 19 #include "machine/upd4701.h" 20 #include "video/315_5313.h" 21 #include "video/segaic16.h" 22 #include "video/sega16sp.h" 23 #include "screen.h" 24 25 26 // ======================> segas18_state 27 28 class segas18_state : public sega_16bit_common_base 29 { 30 public: 31 // construction/destruction segas18_state(const machine_config & mconfig,device_type type,const char * tag)32 segas18_state(const machine_config &mconfig, device_type type, const char *tag) 33 : sega_16bit_common_base(mconfig, type, tag) 34 , m_mapper(*this, "mapper") 35 , m_maincpu(*this, "maincpu") 36 , m_maincpu_region(*this, "maincpu") 37 , m_soundcpu(*this, "soundcpu") 38 , m_mcu(*this, "mcu") 39 , m_vdp(*this, "gen_vdp") 40 , m_io(*this, "io") 41 , m_nvram(*this, "nvram") 42 , m_screen(*this, "screen") 43 , m_sprites(*this, "sprites") 44 , m_segaic16vid(*this, "segaic16vid") 45 , m_gfxdecode(*this, "gfxdecode") 46 , m_upd4701(*this, "upd%u", 1U) 47 , m_workram(*this, "workram") 48 , m_sprites_region(*this, "sprites") 49 , m_soundbank(*this, "soundbank") 50 , m_gun_recoil(*this, "P%u_Gun_Recoil", 1U) 51 , m_romboard(ROM_BOARD_INVALID) 52 , m_custom_io_r(*this) 53 , m_custom_io_w(*this) 54 , m_grayscale_enable(false) 55 , m_vdp_enable(false) 56 , m_vdp_mixing(0) 57 , m_lghost_value(0) 58 , m_lghost_select(0) 59 { 60 } 61 62 void wwally(machine_config &config); 63 void system18(machine_config &config); 64 void lghost_fd1094(machine_config &config); 65 void wwally_fd1094(machine_config &config); 66 void system18_fd1094(machine_config &config); 67 void system18_fd1094_i8751(machine_config &config); 68 void lghost(machine_config &config); 69 void system18_i8751(machine_config &config); 70 71 // driver init 72 void init_ddcrew(); 73 void init_lghost(); 74 void init_generic_shad(); 75 void init_generic_5874(); 76 void init_wwally(); 77 void init_generic_5987(); 78 void init_hamaway(); 79 80 private: 81 // memory mapping 82 void memory_mapper(sega_315_5195_mapper_device &mapper, uint8_t index); 83 84 // read/write handlers 85 void rom_5874_bank_w(uint8_t data); 86 void rom_5987_bank_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 87 void rom_837_7525_bank_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 88 void misc_outputs_w(uint8_t data); 89 uint16_t misc_io_r(address_space &space, offs_t offset, uint16_t mem_mask = ~0); 90 void misc_io_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 91 void soundbank_w(uint8_t data); 92 93 // custom I/O 94 uint16_t ddcrew_custom_io_r(offs_t offset); 95 uint16_t lghost_custom_io_r(offs_t offset); 96 void lghost_gun_recoil_w(uint8_t data); 97 void lghost_custom_io_w(offs_t offset, uint16_t data); 98 uint16_t wwally_custom_io_r(offs_t offset); 99 void wwally_custom_io_w(offs_t offset, uint16_t data); 100 101 // video rendering 102 uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 103 104 DECLARE_WRITE_LINE_MEMBER(vdp_sndirqline_callback_s18); 105 DECLARE_WRITE_LINE_MEMBER(vdp_lv6irqline_callback_s18); 106 DECLARE_WRITE_LINE_MEMBER(vdp_lv4irqline_callback_s18); 107 108 uint16_t genesis_vdp_r(address_space &space, offs_t offset, uint16_t mem_mask = ~0) { return m_vdp->vdp_r(offset, mem_mask); } 109 void genesis_vdp_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask = ~0) { m_vdp->vdp_w(offset, data, mem_mask); } 110 void tileram_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask = ~0) { m_segaic16vid->tileram_w(offset, data, mem_mask); } 111 void textram_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask = ~0) { m_segaic16vid->textram_w(offset, data, mem_mask); } 112 113 DECLARE_WRITE_LINE_MEMBER(set_grayscale); 114 DECLARE_WRITE_LINE_MEMBER(set_vdp_enable); 115 116 void decrypted_opcodes_map(address_map &map); 117 void mcu_io_map(address_map &map); 118 void pcm_map(address_map &map); 119 void sound_map(address_map &map); 120 void sound_portmap(address_map &map); 121 void system18_map(address_map &map); 122 123 // timer IDs 124 enum 125 { 126 TID_INITIAL_BOOST 127 }; 128 129 // rom board types 130 enum segas18_rom_board 131 { 132 ROM_BOARD_INVALID, 133 ROM_BOARD_171_SHADOW, // 171-???? -- used by shadow dancer 134 ROM_BOARD_171_5874, // 171-5874 135 ROM_BOARD_171_5987, // 171-5987 136 ROM_BOARD_837_7525 // Hammer Away proto 137 }; 138 139 // device overrides 140 virtual void machine_start() override; 141 virtual void machine_reset() override; 142 virtual void video_start() override; 143 virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; 144 145 // internal helpers 146 void init_generic(segas18_rom_board rom_board); 147 void set_vdp_mixing(uint8_t mixing); 148 void draw_vdp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority); 149 150 // devices 151 required_device<sega_315_5195_mapper_device> m_mapper; 152 required_device<m68000_device> m_maincpu; 153 required_memory_region m_maincpu_region; 154 required_device<z80_device> m_soundcpu; 155 optional_device<i8751_device> m_mcu; 156 required_device<sega315_5313_device> m_vdp; 157 required_device<sega_315_5296_device> m_io; 158 required_device<nvram_device> m_nvram; 159 required_device<screen_device> m_screen; 160 required_device<sega_sys16b_sprite_device> m_sprites; 161 required_device<segaic16_video_device> m_segaic16vid; 162 required_device<gfxdecode_device> m_gfxdecode; 163 optional_device_array<upd4701_device, 3> m_upd4701; 164 165 // memory pointers 166 required_shared_ptr<uint16_t> m_workram; 167 168 required_memory_region m_sprites_region; 169 optional_memory_bank m_soundbank; 170 171 output_finder<3> m_gun_recoil; 172 173 // configuration 174 segas18_rom_board m_romboard; 175 read16sm_delegate m_custom_io_r; 176 write16sm_delegate m_custom_io_w; 177 178 // internal state 179 int m_grayscale_enable; 180 int m_vdp_enable; 181 uint8_t m_vdp_mixing; 182 bitmap_ind16 m_temp_bitmap; 183 184 // game-specific state 185 uint8_t m_lghost_value; 186 uint8_t m_lghost_select; 187 }; 188 189 #endif // MAME_INCLUDES_SEGAS18_H 190