1 // license:BSD-3-Clause 2 // copyright-holders:Nicola Salmoria 3 #ifndef MAME_INCLUDES_M52_H 4 #define MAME_INCLUDES_M52_H 5 6 #pragma once 7 8 #include "emupal.h" 9 #include "screen.h" 10 #include "tilemap.h" 11 12 class m52_state : public driver_device 13 { 14 public: m52_state(const machine_config & mconfig,device_type type,const char * tag)15 m52_state(const machine_config &mconfig, device_type type, const char *tag) : 16 driver_device(mconfig, type, tag), 17 m_maincpu(*this, "maincpu"), 18 m_screen(*this, "screen"), 19 m_videoram(*this, "videoram"), 20 m_colorram(*this, "colorram"), 21 m_spriteram(*this, "spriteram"), 22 m_sp_gfxdecode(*this, "sp_gfxdecode"), 23 m_tx_gfxdecode(*this, "tx_gfxdecode"), 24 m_bg_gfxdecode(*this, "bg_gfxdecode"), 25 m_sp_palette(*this, "sp_palette"), 26 m_tx_palette(*this, "tx_palette"), 27 m_bg_palette(*this, "bg_palette") 28 { } 29 30 void m52(machine_config &config); 31 32 void m52_videoram_w(offs_t offset, uint8_t data); 33 void m52_colorram_w(offs_t offset, uint8_t data); 34 uint8_t m52_protection_r(); 35 36 protected: 37 virtual void machine_reset() override; 38 virtual void video_start() override; 39 virtual void m52_scroll_w(uint8_t data); 40 41 /* board mod changes? */ 42 int m_spritelimit; 43 bool m_do_bg_fills; 44 45 tilemap_t* m_tx_tilemap; 46 47 required_device<cpu_device> m_maincpu; 48 required_device<screen_device> m_screen; 49 50 private: 51 /* memory pointers */ 52 required_shared_ptr<uint8_t> m_videoram; 53 required_shared_ptr<uint8_t> m_colorram; 54 optional_shared_ptr<uint8_t> m_spriteram; 55 56 /* video-related */ 57 uint8_t m_bg1xpos; 58 uint8_t m_bg1ypos; 59 uint8_t m_bg2xpos; 60 uint8_t m_bg2ypos; 61 uint8_t m_bgcontrol; 62 63 required_device<gfxdecode_device> m_sp_gfxdecode; 64 required_device<gfxdecode_device> m_tx_gfxdecode; 65 required_device<gfxdecode_device> m_bg_gfxdecode; 66 required_device<palette_device> m_sp_palette; 67 required_device<palette_device> m_tx_palette; 68 required_device<palette_device> m_bg_palette; 69 70 void m52_bg1ypos_w(uint8_t data); 71 void m52_bg1xpos_w(uint8_t data); 72 void m52_bg2xpos_w(uint8_t data); 73 void m52_bg2ypos_w(uint8_t data); 74 void m52_bgcontrol_w(uint8_t data); 75 void m52_flipscreen_w(uint8_t data); 76 TILE_GET_INFO_MEMBER(get_tile_info); 77 void init_palette(); 78 template <size_t N, size_t O, size_t P> 79 void init_sprite_palette(const int *resistances_3, const int *resistances_2, double (&weights_r)[N], double (&weights_g)[O], double (&weights_b)[P], double scale); 80 uint32_t screen_update_m52(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 81 void draw_background(bitmap_rgb32 &bitmap, const rectangle &cliprect, int xpos, int ypos, int image); 82 void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, int initoffs); 83 84 void main_map(address_map &map); 85 void main_portmap(address_map &map); 86 }; 87 88 class m52_alpha1v_state : public m52_state 89 { 90 public: m52_alpha1v_state(const machine_config & mconfig,device_type type,const char * tag)91 m52_alpha1v_state(const machine_config &mconfig, device_type type, const char *tag) 92 : m52_state(mconfig, type, tag) 93 { } 94 95 void alpha1v(machine_config &config); 96 97 void alpha1v_map(address_map &map); 98 99 protected: 100 virtual void video_start() override; 101 virtual void m52_scroll_w(uint8_t data) override; 102 void alpha1v_flipscreen_w(uint8_t data); 103 104 }; 105 106 #endif // MAME_INCLUDES_M52_H 107