1 // license:BSD-3-Clause
2 // copyright-holders:Chris Hardy
3 #ifndef MAME_INCLUDES_WARPWARP_H
4 #define MAME_INCLUDES_WARPWARP_H
5 
6 #pragma once
7 
8 #include "machine/74259.h"
9 #include "machine/watchdog.h"
10 #include "audio/geebee.h"
11 #include "audio/warpwarp.h"
12 #include "emupal.h"
13 #include "tilemap.h"
14 
15 class warpwarp_state : public driver_device
16 {
17 public:
warpwarp_state(const machine_config & mconfig,device_type type,const char * tag)18 	warpwarp_state(const machine_config &mconfig, device_type type, const char *tag) :
19 		driver_device(mconfig, type, tag),
20 		m_maincpu(*this, "maincpu"),
21 		m_watchdog(*this, "watchdog"),
22 		m_gfxdecode(*this, "gfxdecode"),
23 		m_warpwarp_sound(*this, "warpwarp_custom"),
24 		m_geebee_sound(*this, "geebee_custom"),
25 		m_geebee_videoram(*this, "geebee_videoram"),
26 		m_videoram(*this, "videoram"),
27 		m_palette(*this, "palette"),
28 		m_latch(*this, "latch"),
29 		m_in0(*this, "IN0"),
30 		m_in1(*this, "IN1"),
31 		m_in2(*this, "IN2"),
32 		m_dsw1(*this, "DSW1"),
33 		m_volin1(*this, "VOLIN1"),
34 		m_volin2(*this, "VOLIN2"),
35 		m_in_config(*this, "CONFIG"),
36 		m_ports(*this, { { "SW0", "SW1", "DSW2", "PLACEHOLDER" } }) // "IN1" & "IN2" are read separately when offset==3
37 	{ }
38 
39 	void warpwarp(machine_config &config);
40 	void geebee(machine_config &config);
41 	void navarone(machine_config &config);
42 	void sos(machine_config &config);
43 	void kaitei(machine_config &config);
44 	void bombbee(machine_config &config);
45 	void geebeeb(machine_config &config);
46 
47 	void init_navarone();
48 	void init_geebee();
49 	void init_kaitein();
50 	void init_warpwarp();
51 	void init_sos();
52 	void init_kaitei();
53 	void init_bombbee();
54 
55 private:
56 	required_device<cpu_device> m_maincpu;
57 	optional_device<watchdog_timer_device> m_watchdog;
58 	required_device<gfxdecode_device> m_gfxdecode;
59 	optional_device<warpwarp_sound_device> m_warpwarp_sound;
60 	optional_device<geebee_sound_device> m_geebee_sound;
61 	optional_shared_ptr<uint8_t> m_geebee_videoram;
62 	optional_shared_ptr<uint8_t> m_videoram;
63 	optional_device<palette_device> m_palette;
64 	optional_device<ls259_device> m_latch;
65 	optional_ioport m_in0;
66 	optional_ioport m_in1;
67 	optional_ioport m_in2;
68 	optional_ioport m_dsw1;
69 	optional_ioport m_volin1;
70 	optional_ioport m_volin2;
71 	optional_ioport m_in_config;
72 	optional_ioport_array<4> m_ports;
73 
74 	int m_geebee_bgw;
75 	int m_ball_on;
76 	int m_ball_h;
77 	int m_ball_v;
78 	int m_ball_pen;
79 	int m_ball_sizex;
80 	int m_ball_sizey;
81 	int m_handle_joystick;
82 	tilemap_t *m_bg_tilemap;
83 
84 	// warpwarp and bombbee
85 	uint8_t warpwarp_sw_r(offs_t offset);
86 	void warpwarp_out0_w(offs_t offset, uint8_t data);
87 	void warpwarp_videoram_w(offs_t offset, uint8_t data);
88 	uint8_t warpwarp_dsw1_r(offs_t offset);
89 	uint8_t warpwarp_vol_r();
90 
91 	//geebee and navarone
92 	uint8_t geebee_in_r(offs_t offset);
93 	void geebee_out6_w(offs_t offset, uint8_t data);
94 	DECLARE_WRITE_LINE_MEMBER(counter_w);
95 	DECLARE_WRITE_LINE_MEMBER(lock_out_w);
96 	DECLARE_WRITE_LINE_MEMBER(geebee_bgw_w);
97 	DECLARE_WRITE_LINE_MEMBER(ball_on_w);
98 	DECLARE_WRITE_LINE_MEMBER(inv_w);
99 	void geebee_videoram_w(offs_t offset, uint8_t data);
100 
101 	virtual void machine_start() override;
102 	DECLARE_MACHINE_RESET(kaitei);
103 
104 	DECLARE_VIDEO_START(geebee);
105 	void geebee_palette(palette_device &palette) const;
106 	DECLARE_VIDEO_START(warpwarp);
107 	void warpwarp_palette(palette_device &palette) const;
108 	DECLARE_VIDEO_START(navarone);
109 	void navarone_palette(palette_device &palette) const;
110 	void sos_palette(palette_device &palette) const;
111 
112 	TILEMAP_MAPPER_MEMBER(tilemap_scan);
113 	TILE_GET_INFO_MEMBER(geebee_get_tile_info);
114 	TILE_GET_INFO_MEMBER(navarone_get_tile_info);
115 	TILE_GET_INFO_MEMBER(warpwarp_get_tile_info);
116 
117 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
118 	inline void plot(bitmap_ind16 &bitmap, const rectangle &cliprect, int x, int y, pen_t pen);
119 	void draw_ball(bitmap_ind16 &bitmap, const rectangle &cliprect,pen_t pen);
120 
121 	DECLARE_WRITE_LINE_MEMBER(vblank_irq);
122 
123 	void bombbee_map(address_map &map);
124 	void geebee_map(address_map &map);
125 	void geebee_port_map(address_map &map);
126 	void warpwarp_map(address_map &map);
127 };
128 
129 #endif // MAME_INCLUDES_WARPWARP_H
130