1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 /***************************************************************************
4 
5     Punch Out / Super Punch Out / Arm Wrestling
6 
7 ***************************************************************************/
8 #ifndef MAME_INCLUDES_PUNCHOUT_H
9 #define MAME_INCLUDES_PUNCHOUT_H
10 
11 #pragma once
12 
13 #include "cpu/m6502/n2a03.h"
14 #include "machine/rp5c01.h"
15 #include "machine/rp5h01.h"
16 #include "sound/vlm5030.h"
17 #include "emupal.h"
18 #include "tilemap.h"
19 
20 class punchout_state : public driver_device
21 {
22 public:
punchout_state(const machine_config & mconfig,device_type type,const char * tag)23 	punchout_state(const machine_config &mconfig, device_type type, const char *tag) :
24 		driver_device(mconfig, type, tag),
25 		m_maincpu(*this, "maincpu"),
26 		m_audiocpu(*this, "audiocpu"),
27 		m_rtc(*this, "rtc"),
28 		m_rp5h01(*this, "rp5h01"),
29 		m_vlm(*this, "vlm"),
30 		m_gfxdecode(*this, "gfxdecode"),
31 		m_palette(*this, "palette"),
32 		m_bg_top_videoram(*this, "bg_top_videoram"),
33 		m_spr1_ctrlram(*this, "spr1_ctrlram"),
34 		m_spr2_ctrlram(*this, "spr2_ctrlram"),
35 		m_palettebank(*this, "palettebank"),
36 		m_spr1_videoram(*this, "spr1_videoram"),
37 		m_spr2_videoram(*this, "spr2_videoram"),
38 		m_bg_bot_videoram(*this, "bg_bot_videoram"),
39 		m_armwrest_fg_videoram(*this, "armwrest_fgram")
40 	{ }
41 
42 	void spnchout(machine_config &config);
43 	void armwrest(machine_config &config);
44 	void punchout(machine_config &config);
45 
46 private:
47 	required_device<cpu_device> m_maincpu;
48 	required_device<n2a03_device> m_audiocpu;
49 	optional_device<rp5c01_device> m_rtc;
50 	optional_device<rp5h01_device> m_rp5h01;
51 	required_device<vlm5030_device> m_vlm;
52 	required_device<gfxdecode_device> m_gfxdecode;
53 	required_device<palette_device> m_palette;
54 
55 	required_shared_ptr<uint8_t> m_bg_top_videoram;
56 	required_shared_ptr<uint8_t> m_spr1_ctrlram;
57 	required_shared_ptr<uint8_t> m_spr2_ctrlram;
58 	required_shared_ptr<uint8_t> m_palettebank;
59 	required_shared_ptr<uint8_t> m_spr1_videoram;
60 	required_shared_ptr<uint8_t> m_spr2_videoram;
61 	required_shared_ptr<uint8_t> m_bg_bot_videoram;
62 	optional_shared_ptr<uint8_t> m_armwrest_fg_videoram;
63 
64 	tilemap_t *m_bg_top_tilemap;
65 	tilemap_t *m_bg_bot_tilemap;
66 	tilemap_t *m_fg_tilemap;
67 	tilemap_t *m_spr1_tilemap;
68 	tilemap_t *m_spr1_tilemap_flipx;
69 	tilemap_t *m_spr2_tilemap;
70 
71 	bool m_nmi_mask;
72 	uint8_t spunchout_exp_r(offs_t offset);
73 	void spunchout_exp_w(offs_t offset, uint8_t data);
74 	void spunchout_rp5h01_reset_w(uint8_t data);
75 	void spunchout_rp5h01_clock_w(uint8_t data);
76 	DECLARE_WRITE_LINE_MEMBER(nmi_mask_w);
77 	void punchout_bg_top_videoram_w(offs_t offset, uint8_t data);
78 	void punchout_bg_bot_videoram_w(offs_t offset, uint8_t data);
79 	void armwrest_fg_videoram_w(offs_t offset, uint8_t data);
80 	void punchout_spr1_videoram_w(offs_t offset, uint8_t data);
81 	void punchout_spr2_videoram_w(offs_t offset, uint8_t data);
82 	TILE_GET_INFO_MEMBER(top_get_info);
83 	TILE_GET_INFO_MEMBER(armwrest_top_get_info);
84 	TILE_GET_INFO_MEMBER(bot_get_info);
85 	TILE_GET_INFO_MEMBER(armwrest_bot_get_info);
86 	TILE_GET_INFO_MEMBER(bs1_get_info);
87 	TILE_GET_INFO_MEMBER(bs2_get_info);
88 	TILE_GET_INFO_MEMBER(armwrest_fg_get_info);
89 	TILEMAP_MAPPER_MEMBER(armwrest_bs1_scan);
90 	TILEMAP_MAPPER_MEMBER(armwrest_bs1_scan_flipx);
91 	virtual void video_start() override;
92 	DECLARE_VIDEO_START(armwrest);
93 	DECLARE_MACHINE_RESET(spnchout);
94 	uint32_t screen_update_punchout_top(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
95 	uint32_t screen_update_punchout_bottom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
96 	uint32_t screen_update_armwrest_top(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
97 	uint32_t screen_update_armwrest_bottom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
98 	DECLARE_WRITE_LINE_MEMBER(vblank_irq);
99 	void draw_big_sprite(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int palette);
100 	void armwrest_draw_big_sprite(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int palette);
101 	void drawbs2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
102 	void punchout_copy_top_palette(int bank);
103 	void punchout_copy_bot_palette(int bank);
104 	void armwrest_map(address_map &map);
105 	void punchout_io_map(address_map &map);
106 	void punchout_map(address_map &map);
107 	void punchout_sound_map(address_map &map);
108 	void punchout_vlm_map(address_map &map);
109 	void spnchout_io_map(address_map &map);
110 };
111 
112 #endif // MAME_INCLUDES_PUNCHOUT_H
113