summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes/carpolo.h
blob: a88746c61c69a913ee4bbbce06813a3bc3ce22ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/***************************************************************************

    Exidy Car Polo hardware

    driver by Zsolt Vasvari

****************************************************************************/

#include "machine/6821pia.h"
#include "machine/7474.h"
#include "machine/74148.h"
#include "machine/74153.h"

class carpolo_state : public driver_device
{
public:
	carpolo_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag),
		m_alpharam(*this, "alpharam"),
		m_spriteram(*this, "spriteram"),
		m_maincpu(*this, "maincpu"),
		m_ttl74148_3s(*this, "74148_3s"),
		m_ttl74153_1k(*this, "74153_1k"),
		m_ttl7474_2s_1(*this, "7474_2s_1"),
		m_ttl7474_2s_2(*this, "7474_2s_2"),
		m_ttl7474_2u_1(*this, "7474_2u_1"),
		m_ttl7474_2u_2(*this, "7474_2u_2"),
		m_ttl7474_1f_1(*this, "7474_1f_1"),
		m_ttl7474_1f_2(*this, "7474_1f_2"),
		m_ttl7474_1d_1(*this, "7474_1d_1"),
		m_ttl7474_1d_2(*this, "7474_1d_2"),
		m_ttl7474_1c_1(*this, "7474_1c_1"),
		m_ttl7474_1c_2(*this, "7474_1c_2"),
		m_ttl7474_1a_1(*this, "7474_1a_1"),
		m_ttl7474_1a_2(*this, "7474_1a_2"),
		m_gfxdecode(*this, "gfxdecode"),
		m_palette(*this, "palette")
		{}

	required_shared_ptr<UINT8> m_alpharam;
	required_shared_ptr<UINT8> m_spriteram;
	UINT8 m_ball_screen_collision_cause;
	UINT8 m_car_ball_collision_x;
	UINT8 m_car_ball_collision_y;
	UINT8 m_car_car_collision_cause;
	UINT8 m_car_goal_collision_cause;
	UINT8 m_car_ball_collision_cause;
	UINT8 m_car_border_collision_cause;
	UINT8 m_priority_0_extension;
	UINT8 m_last_wheel_value[4];
	required_device<cpu_device> m_maincpu;
	required_device<ttl74148_device> m_ttl74148_3s;
	required_device<ttl74153_device> m_ttl74153_1k;
	required_device<ttl7474_device> m_ttl7474_2s_1;
	required_device<ttl7474_device> m_ttl7474_2s_2;
	required_device<ttl7474_device> m_ttl7474_2u_1;
	required_device<ttl7474_device> m_ttl7474_2u_2;
	required_device<ttl7474_device> m_ttl7474_1f_1;
	required_device<ttl7474_device> m_ttl7474_1f_2;
	required_device<ttl7474_device> m_ttl7474_1d_1;
	required_device<ttl7474_device> m_ttl7474_1d_2;
	required_device<ttl7474_device> m_ttl7474_1c_1;
	required_device<ttl7474_device> m_ttl7474_1c_2;
	required_device<ttl7474_device> m_ttl7474_1a_1;
	required_device<ttl7474_device> m_ttl7474_1a_2;
	required_device<gfxdecode_device> m_gfxdecode;
	required_device<palette_device> m_palette;
	
	bitmap_ind16 *m_sprite_sprite_collision_bitmap1;
	bitmap_ind16 *m_sprite_sprite_collision_bitmap2;
	bitmap_ind16 *m_sprite_goal_collision_bitmap1;
	bitmap_ind16 *m_sprite_goal_collision_bitmap2;
	bitmap_ind16 *m_sprite_border_collision_bitmap;
	DECLARE_READ8_MEMBER(carpolo_ball_screen_collision_cause_r);
	DECLARE_READ8_MEMBER(carpolo_car_ball_collision_x_r);
	DECLARE_READ8_MEMBER(carpolo_car_ball_collision_y_r);
	DECLARE_READ8_MEMBER(carpolo_car_car_collision_cause_r);
	DECLARE_READ8_MEMBER(carpolo_car_goal_collision_cause_r);
	DECLARE_READ8_MEMBER(carpolo_car_ball_collision_cause_r);
	DECLARE_READ8_MEMBER(carpolo_car_border_collision_cause_r);
	DECLARE_READ8_MEMBER(carpolo_interrupt_cause_r);
	DECLARE_WRITE8_MEMBER(carpolo_ball_screen_interrupt_clear_w);
	DECLARE_WRITE8_MEMBER(carpolo_car_car_interrupt_clear_w);
	DECLARE_WRITE8_MEMBER(carpolo_car_goal_interrupt_clear_w);
	DECLARE_WRITE8_MEMBER(carpolo_car_ball_interrupt_clear_w);
	DECLARE_WRITE8_MEMBER(carpolo_car_border_interrupt_clear_w);
	DECLARE_WRITE8_MEMBER(carpolo_timer_interrupt_clear_w);
	DECLARE_DRIVER_INIT(carpolo);
	virtual void machine_start();
	virtual void machine_reset();
	virtual void video_start();
	DECLARE_PALETTE_INIT(carpolo);
	UINT32 screen_update_carpolo(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	void screen_eof_carpolo(screen_device &screen, bool state);
	INTERRUPT_GEN_MEMBER(carpolo_timer_interrupt);
	DECLARE_WRITE_LINE_MEMBER(coin1_interrupt_clear_w);
	DECLARE_WRITE_LINE_MEMBER(coin2_interrupt_clear_w);
	DECLARE_WRITE_LINE_MEMBER(coin3_interrupt_clear_w);
	DECLARE_WRITE_LINE_MEMBER(coin4_interrupt_clear_w);
	DECLARE_WRITE8_MEMBER(pia_0_port_a_w);
	DECLARE_WRITE8_MEMBER(pia_0_port_b_w);
	DECLARE_READ8_MEMBER(pia_0_port_b_r);
	DECLARE_READ8_MEMBER(pia_1_port_a_r);
	DECLARE_READ8_MEMBER(pia_1_port_b_r);
	DECLARE_WRITE_LINE_MEMBER(carpolo_7474_2s_1_q_cb);
	DECLARE_WRITE_LINE_MEMBER(carpolo_7474_2s_2_q_cb);
	DECLARE_WRITE_LINE_MEMBER(carpolo_7474_2u_1_q_cb);
	DECLARE_WRITE_LINE_MEMBER(carpolo_7474_2u_2_q_cb);

	void remap_sprite_code(int bank, int code, int *remapped_code, int *flipy);
	void normalize_coordinates(int *x1, int *y1, int *x2, int *y2);
	int check_sprite_left_goal_collision(int x1, int y1, int code1, int flipy1, int goalpost_only);
	int check_sprite_right_goal_collision(int x1, int y1, int code1, int flipy1, int goalpost_only);
	int check_sprite_border_collision(UINT8 x1, UINT8 y1, int code1, int flipy1);
	void carpolo_generate_ball_screen_interrupt(UINT8 cause);
	void carpolo_generate_car_car_interrupt(int car1, int car2);
	void carpolo_generate_car_goal_interrupt(int car, int right_goal);
	void carpolo_generate_car_ball_interrupt(int car, int car_x, int car_y);
	void carpolo_generate_car_border_interrupt(int car, int horizontal_border);
	void draw_sprite(bitmap_ind16 &bitmap, const rectangle &cliprect,
						UINT8 x, UINT8 y, int bank, int code, int col);
	int check_sprite_sprite_collision(int x1, int y1, int code1, int flipy1,
										int x2, int y2, int code2, int flipy2,
										int *col_x, int *col_y);
};


/*----------- defined in machine/carpolo.c -----------*/

void carpolo_74148_3s_cb(device_t *device);