1 // license:BSD-3-Clause 2 // copyright-holders:Aaron Giles 3 /*************************************************************************** 4 5 Videa Gridlee hardware 6 7 driver by Aaron Giles 8 9 ***************************************************************************/ 10 #ifndef MAME_INCLUDES_GRIDLEE_H 11 #define MAME_INCLUDES_GRIDLEE_H 12 13 #pragma once 14 15 #include "sound/samples.h" 16 #include "machine/74259.h" 17 #include "emupal.h" 18 #include "screen.h" 19 20 21 #define GRIDLEE_MASTER_CLOCK (20000000) 22 #define GRIDLEE_CPU_CLOCK (GRIDLEE_MASTER_CLOCK / 16) 23 #define GRIDLEE_PIXEL_CLOCK (GRIDLEE_MASTER_CLOCK / 4) 24 #define GRIDLEE_HTOTAL (0x140) 25 #define GRIDLEE_HBEND (0x000) 26 #define GRIDLEE_HBSTART (0x100) 27 #define GRIDLEE_VTOTAL (0x108) 28 #define GRIDLEE_VBEND (0x010) 29 #define GRIDLEE_VBSTART (0x100) 30 31 32 class gridlee_state : public driver_device 33 { 34 public: gridlee_state(const machine_config & mconfig,device_type type,const char * tag)35 gridlee_state(const machine_config &mconfig, device_type type, const char *tag) : 36 driver_device(mconfig, type, tag), 37 m_spriteram(*this, "spriteram"), 38 m_videoram(*this, "videoram"), 39 m_maincpu(*this, "maincpu"), 40 m_latch(*this, "latch"), 41 m_screen(*this, "screen"), 42 m_palette(*this, "palette"), 43 m_samples(*this, "samples") 44 { } 45 46 void gridlee(machine_config &config); 47 48 private: 49 uint8_t analog_port_r(offs_t offset); 50 uint8_t random_num_r(); 51 DECLARE_WRITE_LINE_MEMBER(coin_counter_w); 52 DECLARE_WRITE_LINE_MEMBER(cocktail_flip_w); 53 void gridlee_videoram_w(offs_t offset, uint8_t data); 54 void gridlee_palette_select_w(uint8_t data); 55 void gridlee_palette(palette_device &palette) const; 56 uint32_t screen_update_gridlee(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 57 TIMER_CALLBACK_MEMBER(irq_off_tick); 58 TIMER_CALLBACK_MEMBER(irq_timer_tick); 59 TIMER_CALLBACK_MEMBER(firq_off_tick); 60 TIMER_CALLBACK_MEMBER(firq_timer_tick); 61 void expand_pixels(); 62 void poly17_init(); 63 void cpu1_map(address_map &map); 64 65 virtual void machine_start() override; 66 virtual void machine_reset() override; 67 virtual void video_start() override; 68 69 required_shared_ptr<uint8_t> m_spriteram; 70 required_shared_ptr<uint8_t> m_videoram; 71 required_device<cpu_device> m_maincpu; 72 required_device<ls259_device> m_latch; 73 required_device<screen_device> m_screen; 74 required_device<palette_device> m_palette; 75 required_device<samples_device> m_samples; 76 77 uint8_t m_last_analog_input[2]; 78 uint8_t m_last_analog_output[2]; 79 std::unique_ptr<uint8_t[]> m_poly17; 80 uint8_t *m_rand17; 81 emu_timer *m_irq_off; 82 emu_timer *m_irq_timer; 83 emu_timer *m_firq_off; 84 emu_timer *m_firq_timer; 85 uint8_t m_cocktail_flip; 86 std::unique_ptr<uint8_t[]> m_local_videoram; 87 uint8_t m_palettebank_vis; 88 }; 89 90 91 /*----------- defined in audio/gridlee.cpp -----------*/ 92 93 class gridlee_sound_device : public device_t, public device_sound_interface 94 { 95 public: 96 gridlee_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); ~gridlee_sound_device()97 ~gridlee_sound_device() { } 98 99 protected: 100 // device-level overrides 101 virtual void device_start() override; 102 103 // sound stream update overrides 104 virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; 105 106 public: 107 void gridlee_sound_w(offs_t offset, uint8_t data); 108 109 private: 110 /* tone variables */ 111 uint32_t m_tone_step; 112 uint32_t m_tone_fraction; 113 uint8_t m_tone_volume; 114 115 /* sound streaming variables */ 116 sound_stream *m_stream; 117 required_device<samples_device> m_samples; 118 double m_freq_to_step; 119 uint8_t m_sound_data[24]; 120 }; 121 122 DECLARE_DEVICE_TYPE(GRIDLEE, gridlee_sound_device) 123 124 #endif // MAME_INCLUDES_GRIDLEE_H 125