1 // license:BSD-3-Clause 2 // copyright-holders:Frank Palazzolo 3 /**************************************************************************** 4 5 Sega "Space Tactics" Driver 6 7 Frank Palazzolo (palazzol@home.com) 8 9 ****************************************************************************/ 10 #ifndef MAME_INCLUDES_STACTICS_H 11 #define MAME_INCLUDES_STACTICS_H 12 13 #pragma once 14 15 #include "machine/74259.h" 16 #include "emupal.h" 17 18 class stactics_state : public driver_device 19 { 20 public: stactics_state(const machine_config & mconfig,device_type type,const char * tag)21 stactics_state(const machine_config &mconfig, device_type type, const char *tag) : 22 driver_device(mconfig, type, tag), 23 m_maincpu(*this, "maincpu"), 24 m_outlatch(*this, "outlatch"), 25 m_display_buffer(*this, "display_buffer"), 26 m_videoram_b(*this, "videoram_b"), 27 m_videoram_d(*this, "videoram_d"), 28 m_videoram_e(*this, "videoram_e"), 29 m_videoram_f(*this, "videoram_f"), 30 m_base_lamps(*this, "base_lamp%u", 0U), 31 m_beam_leds_left(*this, "beam_led_left%u", 0U), 32 m_beam_leds_right(*this, "beam_led_right%u", 0U), 33 m_score_digits(*this, "digit%u", 0U), 34 m_credit_leds(*this, "credit_led%u", 0U), 35 m_barrier_leds(*this, "barrier_led%u", 0U), 36 m_round_leds(*this, "round_led%u", 0U), 37 m_barrier_lamp(*this, "barrier_lamp"), 38 m_start_lamp(*this, "start_lamp"), 39 m_sight_led(*this, "sight_led"), 40 m_in3(*this, "IN3"), 41 m_fake(*this, "FAKE") 42 { } 43 44 void stactics(machine_config &config); 45 46 DECLARE_READ_LINE_MEMBER(frame_count_d3_r); 47 DECLARE_READ_LINE_MEMBER(shot_standby_r); 48 DECLARE_READ_LINE_MEMBER(not_shot_arrive_r); 49 DECLARE_READ_LINE_MEMBER(motor_not_ready_r); 50 DECLARE_CUSTOM_INPUT_MEMBER(get_rng); 51 52 private: 53 uint8_t vert_pos_r(); 54 uint8_t horiz_pos_r(); 55 DECLARE_WRITE_LINE_MEMBER(coin_lockout_1_w); 56 DECLARE_WRITE_LINE_MEMBER(coin_lockout_2_w); 57 DECLARE_WRITE_LINE_MEMBER(palette_bank_w); 58 void scroll_ram_w(offs_t offset, uint8_t data); 59 void speed_latch_w(uint8_t data); 60 void shot_trigger_w(uint8_t data); 61 void shot_flag_clear_w(uint8_t data); 62 DECLARE_WRITE_LINE_MEMBER(motor_w); 63 64 INTERRUPT_GEN_MEMBER(interrupt); 65 66 DECLARE_WRITE_LINE_MEMBER(barrier_lamp_w); 67 DECLARE_WRITE_LINE_MEMBER(start_lamp_w); DECLARE_WRITE_LINE_MEMBER(base_lamp_w)68 template <unsigned N> DECLARE_WRITE_LINE_MEMBER(base_lamp_w) { m_base_lamps[N] = state; } 69 DECLARE_WRITE_LINE_MEMBER(base_2_lamp_w); 70 DECLARE_WRITE_LINE_MEMBER(base_3_lamp_w); 71 DECLARE_WRITE_LINE_MEMBER(base_4_lamp_w); 72 DECLARE_WRITE_LINE_MEMBER(base_5_lamp_w); 73 74 virtual void machine_start() override; 75 virtual void video_start() override; 76 void stactics_palette(palette_device &palette) const; 77 78 uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 79 void update_beam(); 80 inline int get_pixel_on_plane(uint8_t *videoram, uint8_t y, uint8_t x, uint8_t y_scroll); 81 void draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect); 82 template <unsigned N> void set_indicator_leds(unsigned offset, output_finder<N> &outputs, int base_index); 83 void update_artwork(); 84 void move_motor(); 85 86 void stactics_video(machine_config &config); 87 void main_map(address_map &map); 88 89 required_device<cpu_device> m_maincpu; 90 required_device<ls259_device> m_outlatch; 91 92 required_shared_ptr<uint8_t> m_display_buffer; 93 required_shared_ptr<uint8_t> m_videoram_b; 94 required_shared_ptr<uint8_t> m_videoram_d; 95 required_shared_ptr<uint8_t> m_videoram_e; 96 required_shared_ptr<uint8_t> m_videoram_f; 97 98 output_finder<5> m_base_lamps; 99 output_finder<0x40> m_beam_leds_left; 100 output_finder<0x40> m_beam_leds_right; 101 output_finder<6> m_score_digits; 102 output_finder<8> m_credit_leds; 103 output_finder<12> m_barrier_leds; 104 output_finder<16> m_round_leds; 105 output_finder<> m_barrier_lamp; 106 output_finder<> m_start_lamp; 107 output_finder<> m_sight_led; 108 109 required_ioport m_in3; 110 required_ioport m_fake; 111 112 /* machine state */ 113 int m_vert_pos; 114 int m_horiz_pos; 115 bool m_motor_on; 116 117 /* video state */ 118 uint8_t m_y_scroll_d; 119 uint8_t m_y_scroll_e; 120 uint8_t m_y_scroll_f; 121 uint8_t m_frame_count; 122 uint8_t m_shot_standby; 123 uint8_t m_shot_arrive; 124 uint16_t m_beam_state; 125 uint16_t m_old_beam_state; 126 uint16_t m_beam_states_per_frame; 127 uint8_t m_palette_bank; 128 }; 129 130 #endif // MAME_INCLUDES_STACTICS_H 131