1 // license:BSD-3-Clause 2 // copyright-holders:Frank Palazzolo, Stefan Jokisch 3 /* 4 * The schematics don't seem to make a lot of sense when it 5 * comes to the video timing chain:: 6 * 7 * * there are clear typos -- what is H132??? 8 * * there are two HBLANK/HSYNC periods as the horizontal 9 * chain is drawn, which would give an alternating long 10 * line followed by a much shorter one. This cannot be right 11 * * the carry-out/load circuit on LS161@J8 is superfluous 12 * 13 * These values also give a frame rate of about 45Hz, which is 14 * probably too low. I suspect that screen is not really 15 * 512 pixels wide -- most likely 384, which would give 60Hz 16 * 17 * Based on photographs of the PCB, and analysis of videos of 18 * actual gameplay, the horizontal screen really is 384 clocks. 19 * 20 * However, some of the graphics, like the starfield, are 21 * clocked with the 12MHz signal. This effectively doubles 22 * the horizontal resolution: 23 * 24 * 6.048Mhz clocks 12.096Mhz clocks 25 * Horizontal Visible Area 384 (0x180) 768 (0x300) 26 * Horizontal Blanking Time 128 (0x080) 256 (0x100) 27 */ 28 #ifndef MAME_INCLUDES_STARSHP1_H 29 #define MAME_INCLUDES_STARSHP1_H 30 31 #pragma once 32 33 #include "sound/discrete.h" 34 #include "emupal.h" 35 #include "screen.h" 36 #include "tilemap.h" 37 38 39 #define STARSHP1_MASTER_CLOCK (12096000) 40 #define STARSHP1_CPU_CLOCK (STARSHP1_MASTER_CLOCK / 16) 41 #define STARSHP1_PIXEL_CLOCK (STARSHP1_MASTER_CLOCK) 42 #define STARSHP1_HTOTAL (0x300) 43 #define STARSHP1_HBEND (0x000) 44 #define STARSHP1_HBSTART (0x200) 45 #define STARSHP1_VTOTAL (0x106) 46 #define STARSHP1_VBEND (0x000) 47 #define STARSHP1_VBSTART (0x0f0) 48 49 50 class starshp1_state : public driver_device 51 { 52 public: starshp1_state(const machine_config & mconfig,device_type type,const char * tag)53 starshp1_state(const machine_config &mconfig, device_type type, const char *tag) : 54 driver_device(mconfig, type, tag), 55 m_playfield_ram(*this, "playfield_ram"), 56 m_hpos_ram(*this, "hpos_ram"), 57 m_vpos_ram(*this, "vpos_ram"), 58 m_obj_ram(*this, "obj_ram"), 59 m_maincpu(*this, "maincpu"), 60 m_discrete(*this, "discrete"), 61 m_gfxdecode(*this, "gfxdecode"), 62 m_screen(*this, "screen"), 63 m_palette(*this, "palette"), 64 m_led(*this, "led0") 65 { } 66 67 void starshp1(machine_config &config); 68 69 DECLARE_CUSTOM_INPUT_MEMBER(starshp1_analog_r); 70 DECLARE_CUSTOM_INPUT_MEMBER(collision_latch_r); 71 72 private: 73 virtual void machine_start() override; 74 void starshp1_collision_reset_w(uint8_t data); 75 void starshp1_analog_in_w(offs_t offset, uint8_t data); 76 DECLARE_WRITE_LINE_MEMBER(ship_explode_w); 77 DECLARE_WRITE_LINE_MEMBER(circle_mod_w); 78 DECLARE_WRITE_LINE_MEMBER(circle_kill_w); 79 DECLARE_WRITE_LINE_MEMBER(starfield_kill_w); 80 DECLARE_WRITE_LINE_MEMBER(inverse_w); 81 DECLARE_WRITE_LINE_MEMBER(mux_w); 82 DECLARE_WRITE_LINE_MEMBER(led_w); 83 uint8_t starshp1_rng_r(); 84 void starshp1_ssadd_w(offs_t offset, uint8_t data); 85 void starshp1_sspic_w(uint8_t data); 86 void starshp1_playfield_w(offs_t offset, uint8_t data); 87 DECLARE_WRITE_LINE_MEMBER(attract_w); 88 DECLARE_WRITE_LINE_MEMBER(phasor_w); 89 void starshp1_analog_out_w(offs_t offset, uint8_t data); 90 TILE_GET_INFO_MEMBER(get_tile_info); 91 virtual void video_start() override; 92 void starshp1_palette(palette_device &palette) const; 93 uint32_t screen_update_starshp1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 94 DECLARE_WRITE_LINE_MEMBER(screen_vblank_starshp1); 95 INTERRUPT_GEN_MEMBER(starshp1_interrupt); 96 void set_pens(); 97 void draw_starfield(bitmap_ind16 &bitmap); 98 int get_sprite_hpos(int i); 99 int get_sprite_vpos(int i); 100 void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); 101 void draw_spaceship(bitmap_ind16 &bitmap, const rectangle &cliprect); 102 void draw_phasor(bitmap_ind16 &bitmap); 103 int get_radius(); 104 int get_circle_hpos(); 105 int get_circle_vpos(); 106 void draw_circle_line(bitmap_ind16 &bitmap, int x, int y, int l); 107 void draw_circle(bitmap_ind16 &bitmap); 108 int spaceship_collision(bitmap_ind16 &bitmap, const rectangle &rect); 109 int point_in_circle(int x, int y, int center_x, int center_y, int r); 110 int circle_collision(const rectangle &rect); 111 void starshp1_map(address_map &map); 112 113 private: 114 int m_analog_in_select; 115 int m_attract; 116 required_shared_ptr<uint8_t> m_playfield_ram; 117 required_shared_ptr<uint8_t> m_hpos_ram; 118 required_shared_ptr<uint8_t> m_vpos_ram; 119 required_shared_ptr<uint8_t> m_obj_ram; 120 int m_ship_explode; 121 int m_ship_picture; 122 int m_ship_hoffset; 123 int m_ship_voffset; 124 int m_ship_size; 125 int m_circle_hpos; 126 int m_circle_vpos; 127 int m_circle_size; 128 int m_circle_mod; 129 int m_circle_kill; 130 int m_phasor; 131 int m_collision_latch; 132 int m_starfield_kill; 133 int m_mux; 134 int m_inverse; 135 std::unique_ptr<uint16_t[]> m_LSFR; 136 bitmap_ind16 m_helper; 137 tilemap_t *m_bg_tilemap; 138 139 required_device<cpu_device> m_maincpu; 140 required_device<discrete_device> m_discrete; 141 required_device<gfxdecode_device> m_gfxdecode; 142 required_device<screen_device> m_screen; 143 required_device<palette_device> m_palette; 144 output_finder<> m_led; 145 }; 146 147 /*----------- defined in audio/starshp1.c -----------*/ 148 149 DISCRETE_SOUND_EXTERN( starshp1_discrete ); 150 151 /* Discrete Sound Input Nodes */ 152 #define STARSHP1_NOISE_AMPLITUDE NODE_01 153 #define STARSHP1_TONE_PITCH NODE_02 154 #define STARSHP1_MOTOR_SPEED NODE_03 155 #define STARSHP1_NOISE_FREQ NODE_04 156 #define STARSHP1_MOLVL NODE_05 157 #define STARSHP1_SL2 NODE_06 158 #define STARSHP1_SL1 NODE_07 159 #define STARSHP1_KICKER NODE_08 160 #define STARSHP1_PHASOR_ON NODE_09 161 #define STARSHP1_ATTRACT NODE_10 162 163 #endif // MAME_INCLUDES_STARSHP1_H 164