1 // license:BSD-3-Clause 2 // copyright-holders:Nicola Salmoria 3 #ifndef MAME_INCLUDES_BAGMAN_H 4 #define MAME_INCLUDES_BAGMAN_H 5 6 #pragma once 7 8 9 #include "machine/74259.h" 10 #include "sound/tms5110.h" 11 #include "emupal.h" 12 #include "tilemap.h" 13 14 class bagman_state : public driver_device 15 { 16 public: bagman_state(const machine_config & mconfig,device_type type,const char * tag)17 bagman_state(const machine_config &mconfig, device_type type, const char *tag) : 18 driver_device(mconfig, type, tag), 19 m_maincpu(*this, "maincpu"), 20 m_mainlatch(*this, "mainlatch"), 21 m_gfxdecode(*this, "gfxdecode"), 22 m_palette(*this, "palette"), 23 m_tmsprom(*this, "tmsprom"), 24 m_tmslatch(*this, "tmslatch"), 25 m_videoram(*this, "videoram"), 26 m_colorram(*this, "colorram") 27 { } 28 29 void botanic(machine_config &config); 30 void sbagman(machine_config &config); 31 void bagman(machine_config &config); 32 void pickin(machine_config &config); 33 void sbagmani(machine_config &config); 34 35 void init_bagmans3(); 36 37 protected: 38 // common 39 DECLARE_WRITE_LINE_MEMBER(coin_counter_w); 40 DECLARE_WRITE_LINE_MEMBER(irq_mask_w); 41 void videoram_w(offs_t offset, uint8_t data); 42 void colorram_w(offs_t offset, uint8_t data); 43 DECLARE_WRITE_LINE_MEMBER(flipscreen_x_w); 44 DECLARE_WRITE_LINE_MEMBER(flipscreen_y_w); 45 DECLARE_WRITE_LINE_MEMBER(video_enable_w); 46 47 // bagman 48 void ls259_w(offs_t offset, uint8_t data); 49 DECLARE_WRITE_LINE_MEMBER(tmsprom_bit_w); 50 DECLARE_WRITE_LINE_MEMBER(tmsprom_csq0_w); 51 DECLARE_WRITE_LINE_MEMBER(tmsprom_csq1_w); 52 void pal16r6_w(offs_t offset, uint8_t data); 53 uint8_t pal16r6_r(); 54 55 TILE_GET_INFO_MEMBER(get_bg_tile_info); 56 57 virtual void machine_start() override; 58 virtual void machine_reset() override; 59 virtual void video_start() override; 60 void bagman_palette(palette_device &palette) const; 61 62 DECLARE_WRITE_LINE_MEMBER(vblank_irq); 63 64 uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 65 void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); 66 void update_pal(); 67 void bagman_base(machine_config &config); 68 void main_map(address_map &map); 69 void main_portmap(address_map &map); 70 void pickin_map(address_map &map); 71 72 private: 73 required_device<cpu_device> m_maincpu; 74 required_device<ls259_device> m_mainlatch; 75 required_device<gfxdecode_device> m_gfxdecode; 76 required_device<palette_device> m_palette; 77 optional_device<tmsprom_device> m_tmsprom; 78 optional_device<ls259_device> m_tmslatch; 79 80 required_shared_ptr<uint8_t> m_videoram; 81 required_shared_ptr<uint8_t> m_colorram; 82 83 bool m_irq_mask; 84 bool m_video_enable; 85 86 /*table holds outputs of all ANDs (after AND map)*/ 87 uint8_t m_andmap[64]; 88 89 /*table holds inputs (ie. not x, x, not q, q) to the AND map*/ 90 uint8_t m_columnvalue[32]; 91 92 /*8 output pins (actually 6 output and 2 input/output)*/ 93 uint8_t m_outvalue[8]; 94 95 tilemap_t *m_bg_tilemap; 96 }; 97 98 99 class squaitsa_state : public bagman_state 100 { 101 public: squaitsa_state(const machine_config & mconfig,device_type type,const char * tag)102 squaitsa_state(const machine_config &mconfig, device_type type, const char *tag) : 103 bagman_state(mconfig, type, tag), 104 m_dial(*this, "DIAL_P%u", 1), 105 m_res{ 0, 0 }, 106 m_old_val{ 0, 0 } 107 { } 108 109 template <unsigned N> DECLARE_CUSTOM_INPUT_MEMBER(dial_input_r); 110 111 protected: 112 virtual void machine_start() override; 113 114 private: 115 required_ioport_array<2> m_dial; 116 uint8_t m_res[2]; 117 uint8_t m_old_val[2]; 118 }; 119 120 121 /*----------- timings -----------*/ 122 123 #define BAGMAN_MAIN_CLOCK XTAL(18'432'000) 124 #define BAGMAN_HCLK (BAGMAN_MAIN_CLOCK / 3) 125 #define BAGMAN_H0 (BAGMAN_HCLK / 2) 126 #define BAGMAN_H1 (BAGMAN_H0 / 2) 127 #define HTOTAL ((0x100-0x40)*2) 128 #define HBEND (0x00) 129 #define HBSTART (0x100) 130 #define VTOTAL ((0x100-0x7c)*2) 131 132 /* the following VBEND/VBSTART are used for compsync 133 * #define VBEND (0x08) 134 * #define VBSTART (0x100) 135 * 136 * However VBSYQ (and INTQ) is generated using the following values: 137 */ 138 #define VBEND (0x10) 139 #define VBSTART (0xf0) 140 141 #endif // MAME_INCLUDES_BAGMAN_H 142