1 // license:BSD-3-Clause 2 // copyright-holders:Phil Stroffolino 3 /*************************************************************************** 4 5 Namco NA-1 System hardware 6 7 ***************************************************************************/ 8 #ifndef MAME_INCLUDES_NAMCONA1_H 9 #define MAME_INCLUDES_NAMCONA1_H 10 11 #pragma once 12 13 #include "machine/eeprompar.h" 14 #include "machine/namcomcu.h" 15 #include "machine/timer.h" 16 #include "machine/msm6242.h" 17 #include "sound/c140.h" 18 #include "emupal.h" 19 #include "screen.h" 20 #include "tilemap.h" 21 22 23 class namcona1_state : public driver_device 24 { 25 public: namcona1_state(const machine_config & mconfig,device_type type,const char * tag)26 namcona1_state(const machine_config &mconfig, device_type type, const char *tag) : 27 driver_device(mconfig, type, tag), 28 m_maincpu(*this, "maincpu"), 29 m_mcu(*this, "mcu"), 30 m_gfxdecode(*this, "gfxdecode"), 31 m_screen(*this, "screen"), 32 m_palette(*this, "palette"), 33 m_c219(*this, "c219"), 34 m_muxed_inputs(*this, { { "P4", "DSW", "P1", "P2" } }), 35 m_io_p3(*this, "P3"), 36 m_workram(*this, "workram"), 37 m_vreg(*this, "vreg"), 38 m_paletteram(*this, "paletteram"), 39 m_cgram(*this, "cgram"), 40 m_videoram(*this, "videoram"), 41 m_scroll(*this, "scroll"), 42 m_spriteram(*this, "spriteram"), 43 m_prgrom(*this, "maincpu"), 44 m_maskrom(*this, "maskrom"), 45 m_scan_timer(nullptr) 46 { } 47 48 void namcona_base(machine_config &config); 49 void c69(machine_config &config); 50 void namcona1(machine_config &config); 51 52 void init_bkrtmaq(); 53 void init_fa(); 54 void init_cgangpzl(); 55 void init_tinklpit(); 56 void init_swcourt(); 57 void init_exvania(); 58 void init_emeraldj(); 59 void init_swcourtb(); 60 61 void namcona1_mcu_map(address_map &map); 62 63 protected: 64 u16 custom_key_r(offs_t offset); 65 void custom_key_w(u16 data); 66 void vreg_w(offs_t offset, u16 data, u16 mem_mask = ~0); 67 u16 mcu_mailbox_r(offs_t offset); 68 void mcu_mailbox_w_68k(offs_t offset, u16 data, u16 mem_mask = ~0); 69 void mcu_mailbox_w_mcu(offs_t offset, u16 data, u16 mem_mask = ~0); 70 u16 na1mcu_shared_r(offs_t offset); 71 void na1mcu_shared_w(offs_t offset, u16 data, u16 mem_mask = ~0); 72 u8 port4_r(); 73 void port4_w(u8 data); 74 u8 port5_r(); 75 void port5_w(u8 data); 76 u8 port6_r(); 77 void port6_w(u8 data); 78 u8 port7_r(); 79 void port7_w(u8 data); 80 u8 port8_r(); 81 void port8_w(u8 data); 82 template <int Bit> u16 portana_r(); 83 void videoram_w(offs_t offset, u16 data, u16 mem_mask = ~0); 84 void paletteram_w(offs_t offset, u16 data, u16 mem_mask = ~0); 85 u16 gfxram_r(offs_t offset); 86 void gfxram_w(offs_t offset, u16 data, u16 mem_mask = ~0); 87 88 virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; 89 virtual void device_post_load() override; 90 91 u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 92 93 void scanline_interrupt(int scanline); 94 95 void namcona1_main_map(address_map &map); 96 void namcona1_c219_map(address_map &map); 97 98 virtual void machine_start() override; 99 virtual void machine_reset() override; 100 virtual void video_start() override; 101 102 enum 103 { 104 NAMCO_CGANGPZL, 105 NAMCO_EMERALDA, 106 NAMCO_KNCKHEAD, 107 NAMCO_BKRTMAQ, 108 NAMCO_EXVANIA, 109 NAMCO_QUIZTOU, 110 NAMCO_SWCOURT, 111 NAMCO_TINKLPIT, 112 NAMCO_NUMANATH, 113 NAMCO_FA, 114 NAMCO_XDAY2, 115 NAMCO_SWCOURTB 116 }; 117 118 enum 119 { 120 TIMER_SCANLINE 121 }; 122 123 int m_gametype; 124 125 required_device<cpu_device> m_maincpu; 126 required_device<m37710_cpu_device> m_mcu; 127 required_device<gfxdecode_device> m_gfxdecode; 128 required_device<screen_device> m_screen; 129 required_device<palette_device> m_palette; 130 required_device<c219_device> m_c219; 131 132 required_ioport_array<4> m_muxed_inputs; 133 required_ioport m_io_p3; 134 135 required_shared_ptr<u16> m_workram; 136 required_shared_ptr<u16> m_vreg; 137 required_shared_ptr<u16> m_paletteram; 138 required_shared_ptr<u16> m_cgram; 139 required_shared_ptr<u16> m_videoram; 140 required_shared_ptr<u16> m_scroll; 141 required_shared_ptr<u16> m_spriteram; 142 143 required_region_ptr<u16> m_prgrom; 144 required_region_ptr<u16> m_maskrom; 145 146 emu_timer * m_scan_timer; 147 // this has to be u8 to be in the right byte order for the tilemap system 148 std::vector<u8> m_shaperam; 149 150 int m_mEnableInterrupts; 151 u16 m_count; 152 u32 m_keyval; 153 u16 m_mcu_mailbox[8]; 154 u8 m_mcu_port4; 155 u8 m_mcu_port5; 156 u8 m_mcu_port6; 157 u8 m_mcu_port8; 158 tilemap_t *m_bg_tilemap[4+1]; 159 int m_palette_is_dirty; 160 161 void simulate_mcu(); 162 void write_version_info(); 163 int transfer_dword(u32 dest, u32 source); 164 165 void blit(); 166 void UpdatePalette(int offset); 167 void pdraw_tile(screen_device &screen, bitmap_ind16 &dest_bmp, const rectangle &clip, u32 code, u32 color, 168 int sx, int sy, bool flipx, bool flipy, u8 priority, bool bShadow, bool bOpaque, u8 gfx_region); 169 void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 170 void draw_background(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int which, int primask); 171 void tilemap_get_info(tile_data &tileinfo, int tile_index, const u16 *tilemap_videoram, bool use_4bpp_gfx); 172 void blit_setup(int format, int *bytes_per_row, int *pitch, int mode); 173 void draw_pixel_line(const rectangle &cliprect, u16 *pDest, u8 *pPri, u16 *pSource, const pen_t *paldata); 174 bool screen_enabled(const rectangle &cliprect); 175 TILE_GET_INFO_MEMBER(tilemap_get_info0); 176 TILE_GET_INFO_MEMBER(tilemap_get_info1); 177 TILE_GET_INFO_MEMBER(tilemap_get_info2); 178 TILE_GET_INFO_MEMBER(tilemap_get_info3); 179 TILE_GET_INFO_MEMBER(roz_get_info); 180 }; 181 182 class namcona2_state : public namcona1_state 183 { 184 public: namcona2_state(const machine_config & mconfig,device_type type,const char * tag)185 namcona2_state(const machine_config &mconfig, device_type type, const char *tag) : 186 namcona1_state(mconfig, type, tag) 187 {} 188 189 void c70(machine_config &config); 190 void namcona2(machine_config &config); 191 192 void init_knckhead(); 193 void init_emeralda(); 194 void init_numanath(); 195 void init_quiztou(); 196 }; 197 198 class xday2_namcona2_state : public namcona2_state 199 { 200 public: xday2_namcona2_state(const machine_config & mconfig,device_type type,const char * tag)201 xday2_namcona2_state(const machine_config &mconfig, device_type type, const char *tag) : 202 namcona2_state(mconfig, type, tag), 203 m_rtc(*this, "rtc") 204 {} 205 unemulated_features()206 static constexpr feature_type unemulated_features() { return feature::PRINTER; } 207 208 void xday2(machine_config &config); 209 210 void init_xday2(); 211 212 private: 213 required_device <msm6242_device> m_rtc; 214 215 u8 printer_r(); 216 void printer_w(u8 data); 217 218 void xday2_main_map(address_map &map); 219 }; 220 221 #endif // MAME_INCLUDES_NAMCONA1_H 222