1 // license:BSD-3-Clause 2 // copyright-holders:Yochizo 3 4 #include "machine/timer.h" 5 #include "video/jalblend.h" 6 #include "emupal.h" 7 #include "screen.h" 8 #include "tilemap.h" 9 10 class argus_common_state : public driver_device 11 { 12 protected: argus_common_state(const machine_config & mconfig,device_type type,const char * tag)13 argus_common_state(const machine_config &mconfig, device_type type, const char *tag) 14 : driver_device(mconfig, type, tag) 15 , m_maincpu(*this, "maincpu") 16 , m_audiocpu(*this, "audiocpu") 17 , m_gfxdecode(*this, "gfxdecode") 18 , m_screen(*this, "screen") 19 , m_palette(*this, "palette") 20 , m_blend(*this, "blend") 21 , m_bg_scrollx(*this, "bg%u_scrollx", 0U) 22 , m_bg_scrolly(*this, "bg%u_scrolly", 0U) 23 , m_paletteram(*this, "paletteram") 24 , m_txram(*this, "txram") 25 , m_bg1ram(*this, "bg1ram") 26 , m_spriteram(*this, "spriteram") 27 , m_vrom(*this, "vrom%u", 1U) 28 { } 29 30 required_device<cpu_device> m_maincpu; 31 required_device<cpu_device> m_audiocpu; 32 required_device<gfxdecode_device> m_gfxdecode; 33 required_device<screen_device> m_screen; 34 required_device<palette_device> m_palette; 35 required_device<jaleco_blend_device> m_blend; 36 37 optional_shared_ptr_array<u8, 2> m_bg_scrollx; 38 optional_shared_ptr_array<u8, 2> m_bg_scrolly; 39 required_shared_ptr<u8> m_paletteram; 40 optional_shared_ptr<u8> m_txram; 41 optional_shared_ptr<u8> m_bg1ram; 42 required_shared_ptr<u8> m_spriteram; 43 optional_region_ptr_array<u8, 2> m_vrom; 44 45 // common 46 u8 m_bg_status; 47 u8 m_flipscreen; 48 u16 m_palette_intensity; 49 50 // argus specific 51 u8 m_vrom_offset; 52 53 tilemap_t *m_tx_tilemap; 54 tilemap_t *m_bg_tilemap[2]; 55 56 // common 57 void bankselect_w(u8 data); 58 void txram_w(offs_t offset, u8 data); 59 void bg1ram_w(offs_t offset, u8 data); 60 void flipscreen_w(u8 data); 61 62 template<int Gfx> TILE_GET_INFO_MEMBER(get_tx_tile_info); 63 64 virtual void machine_start() override; 65 66 TIMER_DEVICE_CALLBACK_MEMBER(scanline); 67 68 void reset_common(); 69 void change_palette(int color, int lo_offs, int hi_offs); 70 void change_bg_palette(int color, int lo_offs, int hi_offs); 71 void bg_setting(); 72 73 void sound_map_a(address_map &map); 74 void sound_map_b(address_map &map); 75 void sound_portmap_1(address_map &map); 76 void sound_portmap_2(address_map &map); 77 }; 78 79 class argus_state : public argus_common_state 80 { 81 public: argus_state(const machine_config & mconfig,device_type type,const char * tag)82 argus_state(const machine_config &mconfig, device_type type, const char *tag) 83 : argus_common_state(mconfig, type, tag) 84 { } 85 86 void argus(machine_config &config); 87 88 protected: 89 virtual void video_start() override; 90 virtual void video_reset() override; 91 92 private: 93 void bg_status_w(u8 data); 94 void paletteram_w(offs_t offset, u8 data); 95 96 TILE_GET_INFO_MEMBER(get_bg0_tile_info); 97 TILE_GET_INFO_MEMBER(get_bg1_tile_info); 98 99 void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, int priority); 100 u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 101 102 void argus_map(address_map &map); 103 }; 104 105 class valtric_state : public argus_common_state 106 { 107 public: valtric_state(const machine_config & mconfig,device_type type,const char * tag)108 valtric_state(const machine_config &mconfig, device_type type, const char *tag) 109 : argus_common_state(mconfig, type, tag) 110 { } 111 112 void valtric(machine_config &config); 113 114 protected: 115 virtual void video_start() override; 116 virtual void video_reset() override; 117 118 private: 119 void mosaic_w(u8 data); 120 void bg_status_w(u8 data); 121 void paletteram_w(offs_t offset, u8 data); 122 void unknown_w(u8 data); 123 124 TILE_GET_INFO_MEMBER(get_bg_tile_info); 125 126 void draw_mosaic(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 127 void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect); 128 u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 129 130 void valtric_map(address_map &map); 131 132 u8 m_valtric_mosaic; 133 bitmap_rgb32 m_mosaicbitmap; 134 u8 m_valtric_unknown; 135 int m_mosaic; 136 }; 137 138 class butasan_state : public argus_common_state 139 { 140 public: butasan_state(const machine_config & mconfig,device_type type,const char * tag)141 butasan_state(const machine_config &mconfig, device_type type, const char *tag) 142 : argus_common_state(mconfig, type, tag) 143 , m_butasan_bg1ram(*this, "butasan_bg1ram") 144 { } 145 146 void butasan(machine_config &config); 147 148 protected: 149 virtual void video_start() override; 150 virtual void video_reset() override; 151 152 private: 153 void bg0_status_w(u8 data); 154 void bg1_status_w(u8 data); 155 void paletteram_w(offs_t offset, u8 data); 156 void bg1ram_w(offs_t offset, u8 data); 157 void pageselect_w(u8 data); 158 u8 pagedram_r(offs_t offset); 159 void pagedram_w(offs_t offset, u8 data); 160 void unknown_w(u8 data); 161 162 TILE_GET_INFO_MEMBER(get_tx_tile_info); 163 TILE_GET_INFO_MEMBER(get_bg0_tile_info); 164 TILE_GET_INFO_MEMBER(get_bg1_tile_info); 165 TILEMAP_MAPPER_MEMBER(bg_scan); 166 TILEMAP_MAPPER_MEMBER(tx_scan); 167 168 void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect); 169 void log_vram(); 170 u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 171 172 TIMER_DEVICE_CALLBACK_MEMBER(scanline); 173 174 void butasan_map(address_map &map); 175 176 required_shared_ptr<u8> m_butasan_bg1ram; 177 178 u8 *m_butasan_txram; 179 u8 *m_butasan_bg0ram; 180 u8 *m_butasan_bg0backram; 181 u8 *m_butasan_txbackram; 182 std::unique_ptr<u8[]> m_butasan_pagedram[2]; 183 u8 m_butasan_page_latch; 184 u8 m_butasan_bg1_status; 185 u8 m_butasan_unknown; 186 }; 187