1 // license:BSD-3-Clause 2 // copyright-holders:Fabrice Frances, Nicola Salmoria, Aaron Giles 3 /*************************************************************************** 4 5 Gottlieb hardware 6 7 ***************************************************************************/ 8 9 #include "audio/gottlieb.h" 10 #include "cpu/i86/i86.h" 11 #include "cpu/m6502/m6502.h" 12 #include "sound/samples.h" 13 #include "machine/ldpr8210.h" 14 #include "emupal.h" 15 #include "screen.h" 16 #include "tilemap.h" 17 18 19 #define GOTTLIEB_VIDEO_HCOUNT 318 20 #define GOTTLIEB_VIDEO_HBLANK 256 21 #define GOTTLIEB_VIDEO_VCOUNT 256 22 #define GOTTLIEB_VIDEO_VBLANK 240 23 24 25 26 27 // ======================> gottlieb_state 28 29 // shared driver state 30 class gottlieb_state : public driver_device 31 { 32 public: gottlieb_state(const machine_config & mconfig,device_type type,const char * tag)33 gottlieb_state(const machine_config &mconfig, device_type type, const char *tag) 34 : driver_device(mconfig, type, tag) 35 , m_maincpu(*this, "maincpu") 36 , m_laserdisc(*this, "laserdisc") 37 , m_r1_sound(*this, "r1sound") 38 , m_r2_sound(*this, "r2sound") 39 , m_knocker_sample(*this, "knocker_sam") 40 , m_videoram(*this, "videoram") 41 , m_charram(*this, "charram") 42 , m_spriteram(*this, "spriteram") 43 , m_gfxdecode(*this, "gfxdecode") 44 , m_screen(*this, "screen") 45 , m_palette(*this, "palette") 46 , m_paletteram(*this, "paletteram") 47 , m_track_x(*this, "TRACKX") 48 , m_track_y(*this, "TRACKY") 49 , m_leds(*this, "led%u", 0U) 50 { } 51 52 void gottlieb_core(machine_config &config); 53 void cobram3(machine_config &config); 54 void screwloo(machine_config &config); 55 void gottlieb2(machine_config &config); 56 void reactor(machine_config &config); 57 void tylz(machine_config &config); 58 void g2laser(machine_config &config); 59 void qbert(machine_config &config); 60 void qbert_knocker(machine_config &config); 61 void gottlieb1(machine_config &config); 62 void gottlieb1_votrax(machine_config &config); 63 64 void init_romtiles(); 65 void init_screwloo(); 66 void init_vidvince(); 67 void init_ramtiles(); 68 void init_stooges(); 69 void init_qbert(); 70 void init_qbertqub(); 71 72 template <int N> DECLARE_CUSTOM_INPUT_MEMBER(track_delta_r); 73 DECLARE_CUSTOM_INPUT_MEMBER(stooges_joystick_r); 74 75 private: 76 enum 77 { 78 TIMER_LASERDISC_PHILIPS, 79 TIMER_LASERDISC_BIT_OFF, 80 TIMER_LASERDISC_BIT, 81 TIMER_NMI_CLEAR 82 }; 83 84 void qbert_knocker(u8 knock); 85 86 void analog_reset_w(u8 data); 87 void general_output_w(u8 data); 88 void reactor_output_w(u8 data); 89 void stooges_output_w(u8 data); 90 void qbertqub_output_w(u8 data); 91 void qbert_output_w(u8 data); 92 u8 laserdisc_status_r(offs_t offset); 93 void laserdisc_select_w(u8 data); 94 void laserdisc_command_w(u8 data); 95 void sound_w(u8 data); 96 void palette_w(offs_t offset, u8 data); 97 void video_control_w(u8 data); 98 void laserdisc_video_control_w(u8 data); 99 void videoram_w(offs_t offset, u8 data); 100 void charram_w(offs_t offset, u8 data); 101 TILE_GET_INFO_MEMBER(get_bg_tile_info); 102 TILE_GET_INFO_MEMBER(get_screwloo_bg_tile_info); 103 DECLARE_VIDEO_START(screwloo); 104 uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 105 INTERRUPT_GEN_MEMBER(interrupt); 106 TIMER_CALLBACK_MEMBER(laserdisc_philips_callback); 107 TIMER_CALLBACK_MEMBER(laserdisc_bit_off_callback); 108 TIMER_CALLBACK_MEMBER(laserdisc_bit_callback); 109 TIMER_CALLBACK_MEMBER(nmi_clear); 110 void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect); 111 inline void audio_end_state(); 112 void audio_process_clock(bool logit); 113 void audio_handle_zero_crossing(const attotime &zerotime, bool logit); 114 void laserdisc_audio_process(int samplerate, int samples, const int16_t *ch0, const int16_t *ch1); 115 116 void gottlieb_map(address_map &map); 117 void reactor_map(address_map &map); 118 119 virtual void machine_start() override; 120 virtual void machine_reset() override; 121 virtual void video_start() override; 122 virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; 123 124 // devices 125 required_device<cpu_device> m_maincpu; 126 optional_device<pioneer_pr8210_device> m_laserdisc; 127 optional_device<gottlieb_sound_r1_device> m_r1_sound; 128 optional_device<gottlieb_sound_r2_device> m_r2_sound; 129 optional_device<samples_device> m_knocker_sample; 130 131 required_shared_ptr<u8> m_videoram; 132 required_shared_ptr<u8> m_charram; 133 required_shared_ptr<u8> m_spriteram; 134 135 required_device<gfxdecode_device> m_gfxdecode; 136 required_device<screen_device> m_screen; 137 required_device<palette_device> m_palette; 138 required_shared_ptr<u8> m_paletteram; 139 140 optional_ioport m_track_x; 141 optional_ioport m_track_y; 142 output_finder<3> m_leds; // only used by reactor 143 144 u8 m_knocker_prev; 145 u8 m_joystick_select; 146 u8 m_track[2]; 147 emu_timer *m_laserdisc_bit_timer; 148 emu_timer *m_laserdisc_philips_timer; 149 u8 m_laserdisc_select; 150 u8 m_laserdisc_status; 151 uint16_t m_laserdisc_philips_code; 152 std::unique_ptr<u8[]> m_laserdisc_audio_buffer; 153 uint16_t m_laserdisc_audio_address; 154 int16_t m_laserdisc_last_samples[2]; 155 attotime m_laserdisc_last_time; 156 attotime m_laserdisc_last_clock; 157 u8 m_laserdisc_zero_seen; 158 u8 m_laserdisc_audio_bits; 159 u8 m_laserdisc_audio_bit_count; 160 u8 m_gfxcharlo; 161 u8 m_gfxcharhi; 162 u8 m_background_priority; 163 u8 m_spritebank; 164 u8 m_transparent0; 165 tilemap_t *m_bg_tilemap; 166 double m_weights[4]; 167 }; 168