1 // license:BSD-3-Clause 2 // copyright-holders:Vas Crabb 3 /************************************************************************* 4 5 Laser Battle / Lazarian - Cat and Mouse 6 7 *************************************************************************/ 8 #ifndef MAME_INCLUDES_LASERBAT_H 9 #define MAME_INCLUDES_LASERBAT_H 10 11 #pragma once 12 13 #include "audio/zaccaria.h" 14 15 #include "cpu/s2650/s2650.h" 16 17 #include "machine/6821pia.h" 18 #include "machine/pla.h" 19 #include "machine/s2636.h" 20 21 #include "sound/ay8910.h" 22 #include "sound/sn76477.h" 23 #include "sound/tms3615.h" 24 25 #include "emupal.h" 26 #include "screen.h" 27 28 29 class laserbat_state_base : public driver_device 30 { 31 public: laserbat_state_base(const machine_config & mconfig,device_type type,const char * tag)32 laserbat_state_base(const machine_config &mconfig, device_type type, const char *tag) 33 : driver_device(mconfig, type, tag) 34 , m_mux_ports(*this, {"ROW0", "ROW1", "SW1", "SW2"}) 35 , m_row1(*this, "ROW1") 36 , m_row2(*this, "ROW2") 37 , m_maincpu(*this, "maincpu") 38 , m_screen(*this, "screen") 39 , m_palette(*this, "palette") 40 , m_gfxmix(*this, "gfxmix") 41 , m_pvi(*this, "pvi%u", 1U) 42 , m_gfxdecode(*this, "gfxdecode") 43 , m_scanline_timer(nullptr) 44 , m_gfx1(nullptr) 45 , m_gfx2(nullptr) 46 , m_input_mux(0) 47 , m_mpx_p_1_2(false) 48 , m_mpx_bkeff(false) 49 , m_nave(false) 50 , m_clr_lum(0) 51 , m_shp(0) 52 , m_wcoh(0) 53 , m_wcov(0) 54 , m_abeff1(false) 55 , m_abeff2(false) 56 , m_mpx_eff2_sh(false) 57 , m_coleff(0) 58 , m_neg1(false) 59 , m_neg2(false) 60 , m_rhsc(0) 61 , m_whsc(0) 62 , m_csound1(0) 63 , m_csound2(0) 64 { 65 } 66 67 void init_laserbat(); 68 69 void laserbat_base(machine_config &config); 70 void laserbat_io_map(address_map &map); 71 void laserbat_map(address_map &map); 72 73 protected: 74 enum { TIMER_SCANLINE }; 75 76 // control ports 77 void ct_io_w(uint8_t data); 78 uint8_t rrowx_r(); 79 80 INTERRUPT_GEN_MEMBER(laserbat_interrupt); 81 82 // video memory and control ports 83 void videoram_w(offs_t offset, uint8_t data); 84 void wcoh_w(uint8_t data); 85 void wcov_w(uint8_t data); 86 void cnt_eff_w(uint8_t data); 87 void cnt_nav_w(uint8_t data); 88 89 // sound control ports 90 virtual uint8_t rhsc_r(); 91 virtual void whsc_w(uint8_t data); 92 virtual void csound1_w(uint8_t data); 93 virtual void csound2_w(uint8_t data); 94 95 // running the video 96 virtual void video_start() override; 97 uint32_t screen_update_laserbat(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 98 99 virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; 100 101 // video functions 102 TIMER_CALLBACK_MEMBER(video_line); 103 104 // input lines 105 required_ioport_array<4> m_mux_ports; 106 required_ioport m_row1; 107 required_ioport m_row2; 108 109 // main CPU device 110 required_device<s2650_device> m_maincpu; 111 112 // video devices 113 required_device<screen_device> m_screen; 114 required_device<palette_device> m_palette; 115 required_device<pla_device> m_gfxmix; 116 required_device_array<s2636_device, 3> m_pvi; 117 required_device<gfxdecode_device> m_gfxdecode; 118 119 // stuff for rendering video 120 emu_timer *m_scanline_timer; 121 bitmap_ind16 m_bitmap; 122 uint8_t const *m_gfx1; 123 uint8_t const *m_gfx2; 124 125 // control lines 126 unsigned m_input_mux; 127 bool m_mpx_p_1_2; 128 129 // RAM used by TTL video hardware, writable by CPU 130 uint8_t m_bg_ram[0x400]; // background tilemap 131 uint8_t m_eff_ram[0x400]; // per-scanline effects (A8 not wired meaning only half is usable) 132 bool m_mpx_bkeff; // select between writing background and effects memory 133 134 // signals affecting the TTL-generated 32x32 sprite 135 bool m_nave; // 1-bit enable 136 unsigned m_clr_lum; // 3-bit colour/luminance 137 unsigned m_shp; // 3-bit shape 138 unsigned m_wcoh; // 8-bit offset horizontal 139 unsigned m_wcov; // 8-bit offset vertical 140 141 // video effects signals 142 bool m_abeff1; // 1-bit effect enable 143 bool m_abeff2; // 1-bit effect enable 144 bool m_mpx_eff2_sh; // 1-bit effect selection 145 unsigned m_coleff; // 2-bit colour effect 146 bool m_neg1; // 1-bit area selection 147 bool m_neg2; // 1-bit area selection 148 149 // sound board I/O signals 150 unsigned m_rhsc; // 8-bit input from J7 151 unsigned m_whsc; // 8-bit output to J7 152 unsigned m_csound1; // bits 1-8 on J3 153 unsigned m_csound2; // bits 9-16 on J3 154 }; 155 156 157 class laserbat_state : public laserbat_state_base 158 { 159 public: laserbat_state(const machine_config & mconfig,device_type type,const char * tag)160 laserbat_state(const machine_config &mconfig, device_type type, const char *tag) 161 : laserbat_state_base(mconfig, type, tag) 162 , m_csg(*this, "csg") 163 , m_synth_low(*this, "synth_low") 164 , m_synth_high(*this, "synth_high") 165 , m_keys(0) 166 { 167 } 168 169 void laserbat(machine_config &config); 170 171 protected: 172 // initialisation/startup 173 virtual void machine_start() override; 174 175 // video initialisation 176 void laserbat_palette(palette_device &palette) const; 177 178 // sound control ports 179 virtual void csound2_w(uint8_t data) override; 180 181 // sound board devices 182 required_device<sn76477_device> m_csg; 183 required_device<tms3615_device> m_synth_low; 184 required_device<tms3615_device> m_synth_high; 185 186 // register state 187 unsigned m_keys; // low octave keys 1-13 and high octave keys 2-12 (24 bits) 188 }; 189 190 191 class catnmous_state : public laserbat_state_base 192 { 193 public: catnmous_state(const machine_config & mconfig,device_type type,const char * tag)194 catnmous_state(const machine_config &mconfig, device_type type, const char *tag) 195 : laserbat_state_base(mconfig, type, tag) 196 , m_audiopcb(*this, "audiopcb") 197 { 198 } 199 200 void catnmous(machine_config &config); 201 202 protected: 203 204 // video initialisation 205 void catnmous_palette(palette_device &palette) const; 206 207 // sound control ports 208 virtual void csound1_w(uint8_t data) override; 209 virtual void csound2_w(uint8_t data) override; 210 211 required_device<zac1b11107_audio_device> m_audiopcb; 212 }; 213 214 #endif // MAME_INCLUDES_LASERBAT_H 215