1 // license:BSD-3-Clause 2 // copyright-holders:Manuel Abadia, Ernesto Corvi, Nicola Salmoria 3 #ifndef MAME_INCLUDES_GAPLUS_H 4 #define MAME_INCLUDES_GAPLUS_H 5 6 #pragma once 7 8 #include "sound/namco.h" 9 #include "sound/samples.h" 10 #include "machine/namcoio.h" 11 #include "emupal.h" 12 #include "screen.h" 13 #include "tilemap.h" 14 15 class gaplus_base_state : public driver_device 16 { 17 public: 18 static constexpr unsigned MAX_STARS = 250; 19 20 struct star { 21 float x,y; 22 int col,set; 23 }; 24 25 enum 26 { 27 TIMER_NAMCOIO0_RUN, 28 TIMER_NAMCOIO1_RUN 29 }; 30 gaplus_base_state(const machine_config & mconfig,device_type type,const char * tag,const char * namco56xx_tag,const char * namco58xx_tag)31 gaplus_base_state(const machine_config &mconfig, device_type type, const char *tag, const char *namco56xx_tag, const char *namco58xx_tag) 32 : driver_device(mconfig, type, tag) 33 , m_maincpu(*this, "maincpu") 34 , m_subcpu(*this, "sub") 35 , m_subcpu2(*this, "sub2") 36 , m_namco56xx(*this, namco56xx_tag) 37 , m_namco58xx(*this, namco58xx_tag) 38 , m_namco_15xx(*this, "namco") 39 , m_samples(*this, "samples") 40 , m_gfxdecode(*this, "gfxdecode") 41 , m_screen(*this, "screen") 42 , m_palette(*this, "palette") 43 , m_proms_region(*this, "proms") 44 , m_customio_3(*this, "customio_3") 45 , m_videoram(*this, "videoram") 46 , m_spriteram(*this, "spriteram") 47 , m_gfx1_region(*this, "gfx1") 48 , m_gfx2_region(*this, "gfx2") 49 { } 50 51 void irq_1_ctrl_w(offs_t offset, uint8_t data); 52 void irq_2_ctrl_w(offs_t offset, uint8_t data); 53 void irq_3_ctrl_w(offs_t offset, uint8_t data); 54 void sreset_w(offs_t offset, uint8_t data); 55 void freset_w(offs_t offset, uint8_t data); 56 void customio_3_w(offs_t offset, uint8_t data); 57 uint8_t customio_3_r(offs_t offset); 58 void videoram_w(offs_t offset, uint8_t data); 59 void starfield_control_w(offs_t offset, uint8_t data); 60 61 void gaplus_palette(palette_device &palette) const; 62 63 TILEMAP_MAPPER_MEMBER(tilemap_scan); 64 TILE_GET_INFO_MEMBER(get_tile_info); 65 66 DECLARE_WRITE_LINE_MEMBER(vblank_irq); 67 TIMER_CALLBACK_MEMBER(namcoio0_run); 68 TIMER_CALLBACK_MEMBER(namcoio1_run); 69 70 uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 71 DECLARE_WRITE_LINE_MEMBER(screen_vblank); 72 void starfield_init(); 73 void starfield_render(bitmap_ind16 &bitmap); 74 void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ) const; 75 76 void gaplus_base(machine_config &config); 77 void cpu1_map(address_map &map); 78 void cpu2_map(address_map &map); 79 void cpu3_map(address_map &map); 80 81 virtual void driver_init() override; 82 83 protected: 84 virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; 85 virtual void machine_start() override; 86 virtual void machine_reset() override; 87 virtual void video_start() override; 88 89 required_device<cpu_device> m_maincpu; 90 required_device<cpu_device> m_subcpu; 91 required_device<cpu_device> m_subcpu2; 92 required_device<namco56xx_device> m_namco56xx; 93 required_device<namco58xx_device> m_namco58xx; 94 required_device<namco_15xx_device> m_namco_15xx; 95 required_device<samples_device> m_samples; 96 required_device<gfxdecode_device> m_gfxdecode; 97 required_device<screen_device> m_screen; 98 required_device<palette_device> m_palette; 99 required_memory_region m_proms_region; 100 101 required_shared_ptr<uint8_t> m_customio_3; 102 required_shared_ptr<uint8_t> m_videoram; 103 required_shared_ptr<uint8_t> m_spriteram; 104 required_memory_region m_gfx1_region; 105 required_memory_region m_gfx2_region; 106 107 int m_type; 108 109 tilemap_t *m_bg_tilemap; 110 uint8_t m_starfield_control[4]; 111 int m_total_stars; 112 int m_starfield_framecount; 113 struct star m_stars[MAX_STARS]; 114 uint8_t m_main_irq_mask; 115 uint8_t m_sub_irq_mask; 116 uint8_t m_sub2_irq_mask; 117 emu_timer *m_namcoio0_run_timer; 118 emu_timer *m_namcoio1_run_timer; 119 }; 120 121 class gaplusd_state : public gaplus_base_state 122 { 123 public: gaplusd_state(const machine_config & mconfig,device_type type,const char * tag)124 gaplusd_state(const machine_config &mconfig, device_type type, const char *tag) 125 : gaplus_base_state(mconfig, type, tag, "namcoio_2", "namcoio_1") 126 { 127 } 128 129 void gaplusd(machine_config &config); 130 }; 131 132 class gapluso_state : public gaplus_base_state { 133 public: gapluso_state(const machine_config & mconfig,device_type type,const char * tag)134 gapluso_state(const machine_config &mconfig, device_type type, const char *tag) 135 : gaplus_base_state(mconfig, type, tag, "namcoio_1", "namcoio_2") { 136 } 137 138 void gapluso(machine_config &config); 139 140 protected: 141 DECLARE_WRITE_LINE_MEMBER(vblank_irq); 142 }; 143 144 class gaplus_state : public gaplus_base_state { 145 public: gaplus_state(const machine_config & mconfig,device_type type,const char * tag)146 gaplus_state(const machine_config &mconfig, device_type type, const char *tag) 147 : gaplus_base_state(mconfig, type, tag, "namcoio_1", "namcoio_2") 148 , m_lamps(*this, "lamp%u", 0U) 149 { 150 } 151 152 void gaplus(machine_config &config); 153 154 protected: 155 virtual void machine_start() override; 156 157 void out_lamps0(uint8_t data); 158 void out_lamps1(uint8_t data); 159 160 output_finder<2> m_lamps; 161 }; 162 163 #endif // MAME_INCLUDES_GAPLUS_H 164