1 // license:BSD-3-Clause 2 // copyright-holders:Chris Hardy 3 /*************************************************************************** 4 5 Space Firebird hardware 6 7 ****************************************************************************/ 8 9 #ifndef MAME_INCLUDES_SPACEFB 10 #define MAME_INCLUDES_SPACEFB 11 12 #pragma once 13 14 #include "cpu/mcs48/mcs48.h" 15 #include "sound/samples.h" 16 #include "screen.h" 17 /* 18 * SPACEFB_PIXEL_CLOCK clocks the star generator circuit. The rest of 19 * the graphics use a clock half of SPACEFB_PIXEL_CLOCK, thus creating 20 * double width pixels. 21 */ 22 23 #define SPACEFB_MASTER_CLOCK (20160000) 24 #define SPACEFB_MAIN_CPU_CLOCK (6000000 / 2) 25 #define SPACEFB_AUDIO_CPU_CLOCK (6000000) /* this goes to X2, pixel clock goes to X1 */ 26 #define SPACEFB_PIXEL_CLOCK (SPACEFB_MASTER_CLOCK / 2) 27 #define SPACEFB_HTOTAL (0x280) 28 #define SPACEFB_HBEND (0x000) 29 #define SPACEFB_HBSTART (0x200) 30 #define SPACEFB_VTOTAL (0x100) 31 #define SPACEFB_VBEND (0x010) 32 #define SPACEFB_VBSTART (0x0f0) 33 #define SPACEFB_INT_TRIGGER_COUNT_1 (0x080) 34 #define SPACEFB_INT_TRIGGER_COUNT_2 (0x0f0) 35 36 37 class spacefb_state : public driver_device 38 { 39 public: spacefb_state(const machine_config & mconfig,device_type type,const char * tag)40 spacefb_state(const machine_config &mconfig, device_type type, const char *tag) 41 : driver_device(mconfig, type, tag), 42 m_maincpu(*this, "maincpu"), 43 m_audiocpu(*this, "audiocpu"), 44 m_samples(*this, "samples"), 45 m_screen(*this, "screen"), 46 m_videoram(*this, "videoram") { } 47 48 void spacefb(machine_config &config); 49 void spacefb_audio(machine_config &config); 50 51 private: 52 enum 53 { 54 TIMER_INTERRUPT 55 }; 56 57 required_device<cpu_device> m_maincpu; 58 required_device<i8035_device> m_audiocpu; 59 required_device<samples_device> m_samples; 60 required_device<screen_device> m_screen; 61 62 required_shared_ptr<uint8_t> m_videoram; 63 64 uint8_t m_sound_latch; 65 emu_timer *m_interrupt_timer; 66 std::unique_ptr<uint8_t[]> m_object_present_map; 67 uint8_t m_port_0; 68 uint8_t m_port_2; 69 uint32_t m_star_shift_reg; 70 double m_color_weights_rg[3]; 71 double m_color_weights_b[2]; 72 73 void port_0_w(uint8_t data); 74 void port_1_w(uint8_t data); 75 void port_2_w(uint8_t data); 76 uint8_t audio_p2_r(); 77 DECLARE_READ_LINE_MEMBER(audio_t0_r); 78 DECLARE_READ_LINE_MEMBER(audio_t1_r); 79 80 virtual void machine_start() override; 81 virtual void machine_reset() override; 82 virtual void video_start() override; 83 84 TIMER_CALLBACK_MEMBER(interrupt_callback); 85 void start_interrupt_timer(); 86 87 uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 88 inline void shift_star_generator(); 89 void get_starfield_pens(pen_t *pens); 90 void draw_starfield(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 91 void get_sprite_pens(pen_t *pens); 92 void draw_bullet(offs_t offs, pen_t pen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int flip); 93 void draw_sprite(offs_t offs, pen_t *pens, bitmap_rgb32 &bitmap, const rectangle &cliprect, int flip); 94 void draw_objects(bitmap_rgb32 &bitmap, const rectangle &cliprect); 95 96 void spacefb_audio_map(address_map &map); 97 void spacefb_main_io_map(address_map &map); 98 void spacefb_main_map(address_map &map); 99 100 virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; 101 }; 102 103 #endif // MAME_INCLUDES_SPACEFB 104