1 // license:BSD-3-Clause 2 // copyright-holders:Nicola Salmoria, Lee Taylor 3 /************************************************************************* 4 5 Cosmic Guerilla & other Universal boards (in cosmic.c) 6 7 *************************************************************************/ 8 #ifndef MAME_INCLUDES_COSMIC_H 9 #define MAME_INCLUDES_COSMIC_H 10 11 #pragma once 12 13 #include "machine/timer.h" 14 #include "sound/samples.h" 15 #include "sound/dac.h" 16 #include "emupal.h" 17 #include "screen.h" 18 19 #define COSMICG_MASTER_CLOCK XTAL(9'828'000) 20 #define Z80_MASTER_CLOCK XTAL(10'816'000) 21 22 23 class cosmic_state : public driver_device 24 { 25 public: cosmic_state(const machine_config & mconfig,device_type type,const char * tag)26 cosmic_state(const machine_config &mconfig, device_type type, const char *tag) : 27 driver_device(mconfig, type, tag), 28 m_videoram(*this, "videoram"), 29 m_spriteram(*this, "spriteram"), 30 m_in_ports(*this, "IN%u", 0), 31 m_dsw(*this, "DSW"), 32 m_maincpu(*this, "maincpu"), 33 m_samples(*this, "samples"), 34 m_dac(*this, "dac"), 35 m_gfxdecode(*this, "gfxdecode"), 36 m_screen(*this, "screen"), 37 m_palette(*this, "palette") 38 { } 39 40 /* memory pointers */ 41 required_shared_ptr<uint8_t> m_videoram; 42 optional_shared_ptr<uint8_t> m_spriteram; 43 44 /* video-related */ 45 typedef pen_t (cosmic_state::*color_func)(uint8_t x, uint8_t y); 46 color_func m_map_color; 47 int m_color_registers[3]; 48 int m_background_enable; 49 int m_magspot_pen_mask; 50 51 /* sound-related */ 52 int m_sound_enabled; 53 int m_march_select; 54 int m_gun_die_select; 55 int m_dive_bomb_b_select; 56 57 /* misc */ 58 uint32_t m_pixel_clock; 59 int m_ic_state; // for 9980 60 optional_ioport_array<4> m_in_ports; 61 optional_ioport m_dsw; 62 63 /* devices */ 64 required_device<cpu_device> m_maincpu; 65 optional_device<samples_device> m_samples; 66 optional_device<dac_bit_interface> m_dac; 67 optional_device<gfxdecode_device> m_gfxdecode; 68 required_device<screen_device> m_screen; 69 required_device<palette_device> m_palette; 70 71 void panic_sound_output_w(offs_t offset, uint8_t data); 72 void panic_sound_output2_w(offs_t offset, uint8_t data); 73 void cosmicg_output_w(offs_t offset, uint8_t data); 74 void cosmica_sound_output_w(offs_t offset, uint8_t data); 75 void dac_w(uint8_t data); 76 uint8_t cosmica_pixel_clock_r(); 77 uint8_t cosmicg_port_0_r(offs_t offset); 78 uint8_t cosmicg_port_1_r(offs_t offset); 79 uint8_t magspot_coinage_dip_r(offs_t offset); 80 uint8_t nomnlnd_port_0_1_r(offs_t offset); 81 void flip_screen_w(uint8_t data); 82 void cosmic_color_register_w(offs_t offset, uint8_t data); 83 void cosmic_background_enable_w(uint8_t data); 84 DECLARE_WRITE_LINE_MEMBER(panic_coin_inserted); 85 DECLARE_INPUT_CHANGED_MEMBER(cosmica_coin_inserted); 86 DECLARE_INPUT_CHANGED_MEMBER(cosmicg_coin_inserted); 87 DECLARE_INPUT_CHANGED_MEMBER(coin_inserted_irq0); 88 DECLARE_INPUT_CHANGED_MEMBER(coin_inserted_nmi); 89 void init_devzone(); 90 void init_cosmicg(); 91 void init_nomnlnd(); 92 void init_cosmica(); 93 void init_panic(); 94 DECLARE_MACHINE_START(cosmic); 95 DECLARE_MACHINE_RESET(cosmic); 96 DECLARE_MACHINE_RESET(cosmicg); 97 void panic_palette(palette_device &palette); 98 void cosmica_palette(palette_device &palette); 99 void cosmicg_palette(palette_device &palette); 100 void magspot_palette(palette_device &palette); 101 void nomnlnd_palette(palette_device &palette); 102 uint32_t screen_update_cosmicg(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 103 uint32_t screen_update_panic(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 104 uint32_t screen_update_cosmica(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 105 uint32_t screen_update_magspot(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 106 uint32_t screen_update_devzone(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 107 uint32_t screen_update_nomnlnd(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 108 TIMER_DEVICE_CALLBACK_MEMBER(panic_scanline); 109 void draw_bitmap(bitmap_ind16 &bitmap, const rectangle &cliprect); 110 void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int color_mask, int extra_sprites); 111 void cosmica_draw_starfield(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 112 void devzone_draw_grid(bitmap_ind16 &bitmap, const rectangle &cliprect); 113 void nomnlnd_draw_background(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 114 pen_t panic_map_color(uint8_t x, uint8_t y); 115 pen_t cosmica_map_color(uint8_t x, uint8_t y); 116 pen_t cosmicg_map_color(uint8_t x, uint8_t y); 117 pen_t magspot_map_color(uint8_t x, uint8_t y); 118 void cosmic(machine_config &config); 119 void cosmica(machine_config &config); 120 void cosmicg(machine_config &config); 121 void nomnlnd(machine_config &config); 122 void devzone(machine_config &config); 123 void panic(machine_config &config); 124 void magspot(machine_config &config); 125 void cosmica_map(address_map &map); 126 void cosmicg_io_map(address_map &map); 127 void cosmicg_map(address_map &map); 128 void magspot_map(address_map &map); 129 void panic_map(address_map &map); 130 }; 131 132 #endif // MAME_INCLUDES_COSMIC_H 133