1 // license:BSD-3-Clause
2 // copyright-holders:Uki
3 /*************************************************************************
4 
5     Markham (c) 1983 Sun Electronics
6     Strength & Skill (c) 1984 Sun Electronics
7 
8 *************************************************************************/
9 
10 #ifndef MAME_INCLUDES_MARKHAM_H
11 #define MAME_INCLUDES_MARKHAM_H
12 
13 #pragma once
14 
15 #include "machine/timer.h"
16 
17 #include "cpu/z80/z80.h"
18 #include "cpu/mb88xx/mb88xx.h"
19 #include "sound/sn76496.h"
20 #include "emupal.h"
21 #include "screen.h"
22 #include "speaker.h"
23 #include "tilemap.h"
24 
25 class markham_state : public driver_device
26 {
27 public:
28 	// construction/destruction
markham_state(const machine_config & mconfig,device_type type,const char * tag)29 	markham_state(const machine_config &mconfig, device_type type, const char *tag)
30 		: driver_device(mconfig, type, tag)
31 		, m_maincpu(*this, "maincpu")
32 		, m_subcpu(*this, "subcpu")
33 		, m_mcu(*this, "mcu")
34 		, m_sn(*this, "sn%u", 1U)
35 		, m_screen(*this, "screen")
36 		, m_gfxdecode(*this, "gfxdecode")
37 		, m_palette(*this, "palette")
38 		, m_spriteram(*this, "spriteram")
39 		, m_videoram(*this, "videoram")
40 		, m_xscroll(*this, "xscroll")
41 		, m_scroll_ctrl(0)
42 		, m_irq_source(0)
43 		, m_irq_scanline_start(0)
44 		, m_irq_scanline_end(0)
45 		, m_coin2_lock_cnt(3)
46 		, m_packet_buffer{}
47 		, m_packet_write_pos(0)
48 		, m_packet_reset(true)
49 	{
50 	}
51 
52 	void markham(machine_config &config);
53 	void strnskil(machine_config &config);
54 	void banbam(machine_config &config);
55 
56 	void init_common();
57 	void init_banbam();
58 	void init_pettanp();
59 
60 private:
61 	void base_master_map(address_map &map);
62 	void markham_master_map(address_map &map);
63 	void strnskil_master_map(address_map &map);
64 	void banbam_master_map(address_map &map);
65 	void markham_slave_map(address_map &map);
66 	void strnskil_slave_map(address_map &map);
67 
68 	void coin_output_w(uint8_t data);
69 	void flipscreen_w(uint8_t data);
70 	void videoram_w(offs_t offset, uint8_t data);
71 
72 	// markham specific
73 	uint8_t markham_e004_r();
74 
75 	// strnskil specific
76 	uint8_t strnskil_d800_r();
77 	void strnskil_master_output_w(uint8_t data);
78 
79 	// protection comms for banbam/pettanp
80 	uint8_t banbam_protection_r();
81 	void banbam_protection_w(uint8_t data);
82 	void mcu_reset_w(uint8_t data);
83 
84 	virtual void machine_start() override;
85 	virtual void machine_reset() override;
86 	virtual void video_start() override;
87 
88 	uint32_t screen_update_markham(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
89 	uint32_t screen_update_strnskil(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
90 
91 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
92 
93 	void markham_palette(palette_device &palette) const;
94 	DECLARE_VIDEO_START(strnskil);
95 
96 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
97 
98 	TIMER_DEVICE_CALLBACK_MEMBER(strnskil_scanline);
99 
100 	required_device<cpu_device> m_maincpu;
101 	required_device<cpu_device> m_subcpu;
102 	optional_device<mb8841_cpu_device> m_mcu;
103 	required_device_array<sn76496_device, 2> m_sn;
104 	required_device<screen_device> m_screen;
105 	required_device<gfxdecode_device> m_gfxdecode;
106 	required_device<palette_device> m_palette;
107 
108 	/* memory pointers */
109 	required_shared_ptr<uint8_t> m_spriteram;
110 	required_shared_ptr<uint8_t> m_videoram;
111 	required_shared_ptr<uint8_t> m_xscroll;
112 
113 	/* video-related */
114 	tilemap_t *m_bg_tilemap;
115 
116 	uint8_t m_scroll_ctrl;
117 	uint8_t m_irq_source;
118 	uint8_t m_irq_scanline_start;
119 	uint8_t m_irq_scanline_end;
120 
121 	/* misc */
122 	uint8_t m_coin2_lock_cnt;
123 
124 	/* banbam protection simulation */
125 	uint8_t m_packet_buffer[2];
126 	uint8_t m_packet_write_pos;
127 	bool m_packet_reset;
128 
129 	u8 m_strnskil_slave_irq;
130 };
131 
132 #endif // MAME_INCLUDES_MARKHAM_H
133